Repository: diesel-rs/diesel (language: rust)

Issue:
Fix Using unsupported buffer type: 253 (parameter: 1) when trying to use the CLI
Hi @weiznich 

`brew install mysql-client` for macOS will install mysql-client 8.3, but `diesel` CLI thrown such error to Apple fans: https://github.com/diesel-rs/diesel/issues/3929

```
Using unsupported buffer type: 253 (parameter: 1)
```

I autogen [mysqlclient-sys](https://github.com/xiangzhai/mysqlclient-sys) by [rust-bindgen](https://rust-lang.github.io/rust-bindgen/) to support new and old versions about MySQL. And adjusted `diesel` to meet the `diff`.

Could you review the patch please?

Thanks,
Leslie Zhai
SSL_MODE option not behaving correctly with Mysql 5.7
## Setup

### Versions

- **Rust: cargo 1.75.0**
- **Diesel: 2.1.4**
- **Database: Mysql 5.7**
- **Operating System: macOS 14.2.1**

### Feature Flags

- **diesel: mysql**

## Problem Description

When using ssl_mode=DISABLED in the connection string, the mode is not passed to mysql or is ignored

### What are you trying to accomplish?

Connect to Mysql 5.7 database with ssl_mode disabled

### What is the expected output?

The connection to succeed

### What is the actual output?

SSL connection error: error:0A000102:SSL routines::unsupported protocol

### Are you seeing any additional errors?

The following trace is gotten by 

```
 MysqlConnection::establish(&database_url)
        .unwrap_or_else(|_| panic!("Error connecting to {}", database_url))
```

```
Error connecting to mysql://root:changeit@127.0.0.1/northwind?ssl_mode=DISABLED

stack backtrace:
   0:        0x104769844 - std::backtrace_rs::backtrace::libunwind::trace::h2966c6fbfac9d426
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/libunwind.rs:104:5
   1:        0x104769844 - std::backtrace_rs::backtrace::trace_unsynchronized::h8a5f4aefe890b7c5
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:        0x104769844 - std::sys_common::backtrace::_print_fmt::h7574dd98fd39c257
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:67:5
   3:        0x104769844 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h298c9ab285ff3934
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:44:22
   4:        0x10477fff8 - core::fmt::rt::Argument::fmt::hf9661447f7b99899
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/rt.rs:142:9
   5:        0x10477fff8 - core::fmt::write::h4e276abdb6d0c2a1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/fmt/mod.rs:1120:17
   6:        0x104767f44 - std::io::Write::write_fmt::hd421848f5f0bf9d0
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/io/mod.rs:1762:15
   7:        0x104769680 - std::sys_common::backtrace::_print::h09e653c6686dbd70
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:47:5
   8:        0x104769680 - std::sys_common::backtrace::print::hd8bd9ecab1f94b94
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:34:9
   9:        0x10476aaa0 - std::panicking::default_hook::{{closure}}::h520eeb743fc98fb4
  10:        0x10476a7e8 - std::panicking::default_hook::ha6550ffe49b63df1
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:292:9
  11:        0x10476aec8 - std::panicking::rust_panic_with_hook::hddb0e884a202de7c
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:779:13
  12:        0x10476adc8 - std::panicking::begin_panic_handler::{{closure}}::hd2798398a2fd9077
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:657:13
  13:        0x104769cac - std::sys_common::backtrace::__rust_end_short_backtrace::h9201cc364dbb8a23
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
  14:        0x10476ab64 - rust_begin_unwind
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
  15:        0x104789728 - core::panicking::panic_fmt::h4d5168028d4c43c7
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
  16:        0x1046d2a5c - rusttest::establish_connection::{{closure}}::ha7f7982614e6afcb
                               at /Users/toniiltanen/rusttest/src/lib.rs:13:29
  17:        0x1046d28d4 - core::result::Result<T,E>::unwrap_or_else::h05e8fc6f6a7b10f4
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/result.rs:1430:23
  18:        0x1046d2bb4 - rusttest::establish_connection::hbe5b06d199bedfb3
                               at /Users/toniiltanen/rusttest/src/lib.rs:12:5
  19:        0x1046c3f74 - show_customers::main::h77b66616093fa3b5
                               at /Users/toniiltanen/rusttest/src/bin/show_customers.rs:8:27
  20:        0x1046c49b0 - core::ops::function::FnOnce::call_once::h6b86f42d8ff9f8cc
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  21:        0x1046ccaf8 - std::sys_common::backtrace::__rust_begin_short_backtrace::h85e08f78cd4b0e8a
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  22:        0x1046c5aa0 - std::rt::lang_start::{{closure}}::h6fa5e7dccb92eef9
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  23:        0x1047654c0 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h1a7c0e059d971da5
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
  24:        0x1047654c0 - std::panicking::try::do_call::h07a34a23e615022b
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  25:        0x1047654c0 - std::panicking::try::h1111644420b4cc09
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  26:        0x1047654c0 - std::panic::catch_unwind::h31a3b9d6e2ef9973
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  27:        0x1047654c0 - std::rt::lang_start_internal::{{closure}}::h63c3452500a36531
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
  28:        0x1047654c0 - std::panicking::try::do_call::h9c5c8a2a0a297bb7
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
  29:        0x1047654c0 - std::panicking::try::h424cfcafca1bde97
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
  30:        0x1047654c0 - std::panic::catch_unwind::h345d3d448041017f
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
  31:        0x1047654c0 - std::rt::lang_start_internal::h5b246d44f1526226
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  32:        0x1046c5a6c - std::rt::lang_start::h4d3609599c289f9d
                               at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  33:        0x1046c4314 - _main
```

In this photo the results are demostrated:
- the failed use of diesel setup with ssl mode on the connection string env variable
- the failed use of diesel setup with connection string as the cli parameter
- the successful use of mysql cli with ssl mode set to disabled

<img width="1584" alt="Screenshot 2024-01-24 at 12 07 18" src="https://github.com/diesel-rs/diesel/assets/14116472/a3df7f46-e430-44e6-a83a-e2d62ff8c4a4">

### Steps to reproduce

Install Docker image stackupiss/northwind-db:v1, and try to connect.
The connection succeeds with mysql cli with the --ssl-mode parameter, but not with diesel and the parameter on the connection string

## Checklist

- [ x] I have already looked over the [issue tracker](https://github.com/diesel-rs/diesel/issues) and the [discussion forum](https://github.com/diesel-rs/diesel/discussions) for similar possible closed issues.
<!--
If you are unsure if your issue is a duplicate of an existing issue please link the issue in question here
--> 
- [ x] This issue can be reproduced on Rust's stable channel. (Your issue will be
  closed if this is not the case)
- [ x] This issue can be reproduced without requiring a third party crate






Discussion / hints:

Using the provided issue template is mandatory. Please update your issue description to follow the template. You also want to include details why you came to this conclusion. In addition posting images to issues makes it harder for contributors to see your issue. Try to provide a minimal example or the relevant code as text instead.
@weiznich I updated the issue

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 9b79875666c6..ef46d26be975 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -155,6 +155,8 @@ jobs:
           echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV
           echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
           echo "MYSQLCLIENT_LIB_DIR=/usr/local/opt/mariadb@10.5/lib" >> $GITHUB_ENV
+          echo "MYSQLCLIENT_VERSION=10.5" >> $GITHUB_ENV
+
 
       - name: Install mysql (MacOS M1)
         if: matrix.os == 'macos-14' && matrix.backend == 'mysql'
@@ -169,6 +171,7 @@ jobs:
           echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://runner@localhost/diesel_example" >> $GITHUB_ENV
           echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://runner@localhost/diesel_unit_test" >> $GITHUB_ENV
           echo "MYSQLCLIENT_LIB_DIR=/opt/homebrew/opt/mariadb@10.5/lib" >> $GITHUB_ENV
+          echo "MYSQLCLIENT_VERSION=10.5" >> $GITHUB_ENV
 
       - name: Install sqlite (Windows)
         if: runner.os == 'Windows' && matrix.backend == 'sqlite'
@@ -213,6 +216,7 @@ jobs:
           echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root@localhost/diesel_example" >> $GITHUB_ENV
           echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root@localhost/diesel_unit_test" >> $GITHUB_ENV
           echo "MYSQLCLIENT_LIB_DIR=C:\tools\mysql\current\lib" >> $GITHUB_ENV
+          echo "MYSQLCLIENT_VERSION=8.0.31" >> $GITHUB_ENV
           echo "C:\tools\mysql\current\lib" >> $GITHUB_PATH
           echo "C:\tools\mysql\current\bin" >> $GITHUB_PATH
           dir "C:\tools\mysql\current\lib"
@@ -421,9 +425,8 @@ jobs:
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v4
-      - uses: dtolnay/rust-toolchain@master
+      - uses: dtolnay/rust-toolchain@stable
         with:
-          toolchain: nightly
           components: "rust-src"
       - name: Cache cargo registry
         uses: Swatinem/rust-cache@v2
@@ -431,33 +434,36 @@ jobs:
           key: sqlite_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}
 
       - name: Test diesel-cli
-        run: cargo +nightly test --manifest-path diesel_cli/Cargo.toml --no-default-features --features "sqlite-bundled"
+        run: cargo +stable test --manifest-path diesel_cli/Cargo.toml --no-default-features --features "sqlite-bundled"
 
       - name: Run diesel_tests with ASAN enabled
         env:
+          RUSTC_BOOTSTRAP: 1
           RUSTFLAGS: -Zsanitizer=address
           ASAN_OPTIONS: detect_stack_use_after_return=1
-        run: cargo +nightly -Z build-std test --manifest-path diesel_tests/Cargo.toml --no-default-features --features "sqlite libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu
+        run: cargo +stable -Z build-std test --manifest-path diesel_tests/Cargo.toml --no-default-features --features "sqlite libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu
 
       - name: Run diesel tests with ASAN enabled
         env:
+          RUSTC_BOOTSTRAP: 1
           RUSTDOCFLAGS: -Zsanitizer=address
           RUSTFLAGS: -Zsanitizer=address
           ASAN_OPTIONS: detect_stack_use_after_return=1
-        run: cargo +nightly -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu
+        run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "sqlite extras libsqlite3-sys libsqlite3-sys/bundled libsqlite3-sys/with-asan" --target x86_64-unknown-linux-gnu
+
   postgres_bundled:
     name: Check postgres bundled + Postgres with asan
     runs-on: ubuntu-latest
     steps:
-      - uses: actions/checkout@v3
-      - uses: dtolnay/rust-toolchain@master
+      - uses: actions/checkout@v4
+      - uses: dtolnay/rust-toolchain@stable
         with:
-          toolchain: nightly
           components: "rust-src"
       - name: Cache cargo registry
         uses: Swatinem/rust-cache@v2
         with:
           key: postgres_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}
+
       - name: Install postgres (Linux)
         run: |
           sudo apt-get update
@@ -470,20 +476,74 @@ jobs:
           echo $PG_DATABASE_URL
 
       - name: Test diesel-cli
-        run: cargo +nightly test --manifest-path diesel_cli/Cargo.toml --no-default-features --features "postgres-bundled"
+        run: cargo +stable test --manifest-path diesel_cli/Cargo.toml --no-default-features --features "postgres-bundled"
 
       - name: Run diesel_tests with ASAN enabled
         env:
+          RUSTC_BOOTSTRAP: 1
           RUSTFLAGS: -Zsanitizer=address
           ASAN_OPTIONS: detect_stack_use_after_return=1
-        run: cargo +nightly -Z build-std test --manifest-path diesel_tests/Cargo.toml --no-default-features --features "postgres pq-sys pq-sys/bundled pq-src/with-asan" --target x86_64-unknown-linux-gnu
+        run: cargo +stable -Z build-std test --manifest-path diesel_tests/Cargo.toml --no-default-features --features "postgres pq-sys pq-sys/bundled pq-src/with-asan" --target x86_64-unknown-linux-gnu
 
       - name: Run diesel tests with ASAN enabled
         env:
+          RUSTC_BOOTSTRAP: 1
           RUSTDOCFLAGS: -Zsanitizer=address
           RUSTFLAGS: -Zsanitizer=address
           ASAN_OPTIONS: detect_stack_use_after_return=1
-        run: cargo +nightly -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "postgres pq-sys pq-sys/bundled pq-src/with-asan" --target x86_64-unknown-linux-gnu
+        run: cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "postgres pq-sys pq-sys/bundled pq-src/with-asan" --target x86_64-unknown-linux-gnu
+
+  mysql_bundled:
+    name: Check mysql bundled + Mysql with asan
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v4
+      - uses: dtolnay/rust-toolchain@stable
+        with:
+          components: "rust-src"
+      - name: Cache cargo registry
+        uses: Swatinem/rust-cache@v2
+        with:
+          key: mysql_bundled-cargo-${{ hashFiles('**/Cargo.toml') }}
+      - name: Install Mysql (Linux)
+        run: |
+          sudo systemctl start mysql.service
+          sudo apt-get update
+          sudo apt-get -y install libmysqlclient-dev llvm
+          mysql -e "create database diesel_test; create database diesel_unit_test; grant all on \`diesel_%\`.* to 'root'@'localhost';" -uroot -proot
+          echo "MYSQL_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_test" >> $GITHUB_ENV
+          echo "MYSQL_EXAMPLE_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_example" >> $GITHUB_ENV
+          echo "MYSQL_UNIT_TEST_DATABASE_URL=mysql://root:root@127.0.0.1/diesel_unit_test" >> $GITHUB_ENV
+
+      - name: Test diesel-cli
+        env:
+          RUST_TEST_THREADS: 1
+        run: cargo +stable test --manifest-path diesel_cli/Cargo.toml --no-default-features --features "mysql-bundled"
+
+      - name: Run diesel_tests with ASAN enabled
+        env:
+          RUSTC_BOOTSTRAP: 1
+          RUSTFLAGS: -Zsanitizer=address
+          RUST_TEST_THREADS: 1
+          ASAN_OPTIONS: symbolize=1,detect_stack_use_after_return=1
+          ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer
+          LSAN_OPTIONS: suppressions=/tmp/suppr.txt
+        run: |
+          echo "leak:mysql_server_init" > /tmp/suppr.txt
+          cargo +stable -Z build-std test --manifest-path diesel_tests/Cargo.toml --no-default-features --features "mysql mysqlclient-sys mysqlclient-sys/bundled mysqlclient-src/with-asan" --target x86_64-unknown-linux-gnu
+
+      - name: Run diesel tests with ASAN enabled
+        env:
+          RUSTC_BOOTSTRAP: 1
+          RUSTDOCFLAGS: -Zsanitizer=address
+          RUSTFLAGS: -Zsanitizer=address
+          RUST_TEST_THREADS: 1
+          ASAN_OPTIONS: symbolize=1,detect_stack_use_after_return=1
+          ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer
+          LSAN_OPTIONS: suppressions=/tmp/suppr.txt
+        run: |
+          echo "leak:mysql_server_init" > /tmp/suppr.txt
+          cargo +stable -Z build-std test --manifest-path diesel/Cargo.toml --no-default-features --features "mysql mysqlclient-sys mysqlclient-sys/bundled mysqlclient-src/with-asan" --target x86_64-unknown-linux-gnu
 
   minimal_rust_version:
     name: Check Minimal supported rust version (1.78.0)
diff --git a/diesel/Cargo.toml b/diesel/Cargo.toml
index 971ebd10aae3..e7041477669a 100644
--- a/diesel/Cargo.toml
+++ b/diesel/Cargo.toml
@@ -17,7 +17,8 @@ byteorder = { version = "1.0", optional = true }
 chrono = { version = "0.4.20", optional = true, default-features = false, features = ["clock", "std"] }
 libc = { version = "0.2.0", optional = true }
 libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true, features = ["bundled_bindings"] }
-mysqlclient-sys = { version = "0.2.5", optional = true }
+mysqlclient-sys = { version = ">=0.2.5, <0.4.0",  optional = true }
+mysqlclient-src = { version = "0.1.0", optional = true }
 pq-sys = { version = ">=0.4.0, <0.7.0", optional = true }
 pq-src = { version = "0.1", optional = true }
 quickcheck = { version = "1.0.3", optional = true }
diff --git a/diesel/src/mysql/connection/bind.rs b/diesel/src/mysql/connection/bind.rs
index 5ce7202e380f..39a6038bdce2 100644
--- a/diesel/src/mysql/connection/bind.rs
+++ b/diesel/src/mysql/connection/bind.rs
@@ -375,9 +375,9 @@ impl BindData {
     }
 
     fn from_tpe_and_flags((tpe, flags): (ffi::enum_field_types, Flags)) -> Self {
-        let mut bytes = known_buffer_size_for_ffi_type(tpe)
-            .map(|len| vec![0; len])
-            .unwrap_or_default();
+        // newer mysqlclient versions do not accept a zero sized buffer
+        let len = known_buffer_size_for_ffi_type(tpe).unwrap_or(1);
+        let mut bytes = vec![0; len];
         let length = bytes.len() as libc::c_ulong;
         let capacity = bytes.capacity();
         let ptr = NonNull::new(bytes.as_mut_ptr());
@@ -389,13 +389,13 @@ impl BindData {
             length,
             capacity,
             flags,
-            is_null: 0,
-            is_truncated: Some(0),
+            is_null: ffi::FALSE,
+            is_truncated: Some(ffi::FALSE),
         }
     }
 
     fn is_truncated(&self) -> bool {
-        self.is_truncated.unwrap_or(0) != 0
+        self.is_truncated.unwrap_or(ffi::FALSE) != ffi::FALSE
     }
 
     fn is_fixed_size_buffer(&self) -> bool {
@@ -423,7 +423,7 @@ impl BindData {
     }
 
     pub(super) fn is_null(&self) -> bool {
-        self.is_null != 0
+        self.is_null != ffi::my_bool::default()
     }
 
     fn update_buffer_length(&mut self) {
@@ -711,6 +711,13 @@ impl From<(ffi::enum_field_types, Flags)> for MysqlType {
                  something has gone wrong. Please open an issue at \
                  the diesel github repo."
             ),
+
+            t => unreachable!(
+                "Unsupported type encountered: {t:?}. \
+                 If you ever see this error, something has gone wrong. \
+                 Please open an issue at the diesel github \
+                 repo in this case."
+            ),
         }
     }
 }
@@ -1261,7 +1268,7 @@ mod tests {
             capacity,
             length,
             flags,
-            is_null: 0,
+            is_null: ffi::FALSE,
             is_truncated: None,
         };
 
@@ -1277,7 +1284,7 @@ mod tests {
             capacity,
             length,
             flags: Flags::empty(),
-            is_null: 0,
+            is_null: ffi::FALSE,
             is_truncated: None,
         };
 
diff --git a/diesel/src/mysql/connection/raw.rs b/diesel/src/mysql/connection/raw.rs
index abbe270068a2..f73f2b815454 100644
--- a/diesel/src/mysql/connection/raw.rs
+++ b/diesel/src/mysql/connection/raw.rs
@@ -175,7 +175,7 @@ impl RawConnection {
     }
 
     fn more_results(&self) -> bool {
-        unsafe { ffi::mysql_more_results(self.0.as_ptr()) != 0 }
+        unsafe { ffi::mysql_more_results(self.0.as_ptr()) != ffi::FALSE }
     }
 
     fn next_result(&self) -> QueryResult<()> {
@@ -243,7 +243,7 @@ impl Drop for RawConnection {
 /// > to protect the `mysql_library_init()` call. This should be done prior to
 /// > any other client library call.
 ///
-/// <https://dev.mysql.com/doc/refman/5.7/en/mysql-init.html>
+/// <https://dev.mysql.com/doc/c-api/8.4/en/mysql-init.html>
 static MYSQL_THREAD_UNSAFE_INIT: Once = Once::new();
 
 fn perform_thread_unsafe_library_initialization() {
diff --git a/diesel_cli/Cargo.toml b/diesel_cli/Cargo.toml
index 1e4b2d5d7dec..2f058e0ea97d 100644
--- a/diesel_cli/Cargo.toml
+++ b/diesel_cli/Cargo.toml
@@ -37,6 +37,7 @@ url = { version = "2.2.2" }
 libsqlite3-sys = { version = ">=0.17.2, <0.29.0", optional = true }
 pq-sys = { version = ">=0.4, <0.7.0", optional = true }
 openssl-sys = { version = "0.9.93", features = ["vendored"], optional = true }
+mysqlclient-sys = { version = ">=0.2.5, <0.4.0", optional = true }
 diffy = "0.3.0"
 regex = "1.0.6"
 serde_regex = "1.1"
@@ -66,7 +67,8 @@ postgres = ["diesel/postgres", "uses_information_schema"]
 sqlite = ["diesel/sqlite"]
 mysql = ["diesel/mysql", "uses_information_schema"]
 sqlite-bundled = ["sqlite", "libsqlite3-sys/bundled"]
-postgres-bundled = ["postgres", "pq-sys/bundled", "openssl-sys"]
+postgres-bundled = ["postgres", "pq-sys/bundled"]
+mysql-bundled = ["mysql", "mysqlclient-sys/bundled"]
 uses_information_schema = []
 
 [[test]]


Test patch:
diff --git a/diesel_compile_tests/Cargo.lock b/diesel_compile_tests/Cargo.lock
index 48669bec4793..f1e606195d87 100644
--- a/diesel_compile_tests/Cargo.lock
+++ b/diesel_compile_tests/Cargo.lock
@@ -356,9 +356,9 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
 
 [[package]]
 name = "mysqlclient-sys"
-version = "0.2.5"
+version = "0.3.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f61b381528ba293005c42a409dd73d034508e273bf90481f17ec2e964a6e969b"
+checksum = "bd59c034806974df483883503e8a019b1a0137b0e60dd64811537ab56312ad2d"
 dependencies = [
  "pkg-config",
  "vcpkg",
diff --git a/diesel_tests/Cargo.toml b/diesel_tests/Cargo.toml
index 3ce7cf50c300..a36f76bab118 100644
--- a/diesel_tests/Cargo.toml
+++ b/diesel_tests/Cargo.toml
@@ -24,6 +24,8 @@ rand = "0.8.4"
 libsqlite3-sys = { version = "0.28", optional = true }
 pq-sys = { version = "0.5", optional = true }
 pq-src = { version = "0.1.1", optional = true }
+mysqlclient-sys = { version = ">=0.2.5, <0.4.0", optional = true }
+mysqlclient-src = { version = "0.1.0", optional = true }
 
 [features]
 default = []