Skip to content
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 25 commits into from
Jun 10, 2020

Commits on Jun 3, 2020

  1. 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.
    sgrif authored and weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    217dd1a View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a16c576 View commit details
    Browse the repository at this point in the history
  3. Improve type mapping in mysql backend

    Also add some links to relevant mysql/mariadb documentation there
    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    5b80a18 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    3cc4192 View commit details
    Browse the repository at this point in the history
  5. 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
    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    b285e5c View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    4cd1db8 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    de0b452 View commit details
    Browse the repository at this point in the history
  8. 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]`
    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    2facb24 View commit details
    Browse the repository at this point in the history
  9. More type fixes

    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    d1eed7c View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    0b6c61e View commit details
    Browse the repository at this point in the history
  11. Fix CI

    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    2300231 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    6ea97a3 View commit details
    Browse the repository at this point in the history
  13. Rustfmt

    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    67aceb2 View commit details
    Browse the repository at this point in the history
  14. Fix custom types example

    weiznich committed Jun 3, 2020
    Configuration menu
    Copy the full SHA
    8325d51 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    6ac48a7 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    94e66ed View commit details
    Browse the repository at this point in the history

Commits on Jun 4, 2020

  1. Fix diesel-rs#2373

    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.
    weiznich committed Jun 4, 2020
    Configuration menu
    Copy the full SHA
    1b0453f View commit details
    Browse the repository at this point in the history

Commits on Jun 5, 2020

  1. Configuration menu
    Copy the full SHA
    54ffbf3 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    db56fce View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    5668b75 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    f94495a View commit details
    Browse the repository at this point in the history
  5. Add back default features

    weiznich committed Jun 5, 2020
    Configuration menu
    Copy the full SHA
    1d46c44 View commit details
    Browse the repository at this point in the history

Commits on Jun 8, 2020

  1. Address review comments

    weiznich committed Jun 8, 2020
    Configuration menu
    Copy the full SHA
    9ad9558 View commit details
    Browse the repository at this point in the history

Commits on Jun 10, 2020

  1. Configuration menu
    Copy the full SHA
    f783850 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    a1d71bb View commit details
    Browse the repository at this point in the history