From f5ee5107dcf82adde6bc585d03e3e997e182d4cf Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Fri, 25 Mar 2022 18:00:38 +0100 Subject: [PATCH] improve error message then setting odbc version --- Cargo.lock | 12 ++++++------ Changelog.md | 4 ++++ odbc-api/Cargo.toml | 4 ++-- odbc-api/src/environment.rs | 12 ++++++++---- odbc-api/src/error.rs | 7 ++++--- odbcsv/Cargo.toml | 4 ++-- odbcsv/Changelog.md | 4 ++++ 7 files changed, 30 insertions(+), 17 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f017a1b1..2b7e7268 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -736,7 +736,7 @@ dependencies = [ [[package]] name = "odbc-api" -version = "0.36.0" +version = "0.36.1" dependencies = [ "anyhow", "csv", @@ -760,7 +760,7 @@ checksum = "5fa96a125cee9f1fe33cb69d6517466afc4e9cb1f44afdcc67210e2776aec7b2" [[package]] name = "odbcsv" -version = "0.3.65" +version = "0.3.66" dependencies = [ "anyhow", "assert_cmd", @@ -915,9 +915,9 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.2.11" +version = "0.2.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" +checksum = "8ae183fc1b06c149f0c1793e1eb447c8b04bfe46d48e9e48bfb8d2d7ed64ecf0" dependencies = [ "bitflags", ] @@ -1064,9 +1064,9 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] name = "test-case" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b712a2c4665154f693a4d2e7601f321ef9be194a4bc1ea16c90ea1f71a14e5c" +checksum = "6344589a99d3971d6fa4e8314dbcbeca2df6273a6b642e46906971779159af1f" dependencies = [ "cfg-if 1.0.0", "proc-macro-error", diff --git a/Changelog.md b/Changelog.md index 1c53b2a2..743c6d44 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## 0.36.1 + +* If setting the ODBC version fails with `HY092` (Invalid attribute value), the user will now see an error message stating that likely the ODBC driver manager should be updated as it does not seem to support ODBC version 3.80. This gives the user a better starting point to fix the problem than just the diagnostic record. + ## 0.36.0 * Introduce `AnyColumnView::Text` and `AnyColumnView::WText` now holds a `TextColumnView` instead of a `TextColumnIt`. To get the iterator you can just call `iter()` on the `TextColumnView`. diff --git a/odbc-api/Cargo.toml b/odbc-api/Cargo.toml index 2401a228..92289804 100644 --- a/odbc-api/Cargo.toml +++ b/odbc-api/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "odbc-api" -version = "0.36.0" +version = "0.36.1" authors = ["Markus Klein"] edition = "2021" license = "MIT" @@ -72,5 +72,5 @@ lazy_static = "1.4.0" env_logger = "0.9.0" anyhow = "1.0.56" csv = "1.1.6" -test-case = "2.0.1" +test-case = "2.0.2" tempfile = "3.3.0" diff --git a/odbc-api/src/environment.rs b/odbc-api/src/environment.rs index 8c3f6675..962e5a1c 100644 --- a/odbc-api/src/environment.rs +++ b/odbc-api/src/environment.rs @@ -152,12 +152,16 @@ impl Environment { // Translate invalid attribute into a more meaningful error, provided the additional // context that we know we tried to set version number. - result.provide_context_for_diagnostic(|record, function| { - if record.state == State::INVALID_STATE_TRANSACTION { + result.provide_context_for_diagnostic(|record, function| match record.state { + // INVALID_STATE_TRANSACTION has been seen with some really old version of unixODBC on + // a CentOS used to build manylinux wheels, with the preinstalled ODBC version. + // INVALID_ATTRIBUTE_VALUE is the correct status code to emit for a driver manager if it + // does not know the version and has been seen with an unknown version of unixODBC on an + // Oracle Linux. + State::INVALID_STATE_TRANSACTION | State::INVALID_ATTRIBUTE_VALUE => { Error::UnsupportedOdbcApiVersion(record) - } else { - Error::Diagnostics { record, function } } + _ => Error::Diagnostics { record, function }, })?; Ok(Self { diff --git a/odbc-api/src/error.rs b/odbc-api/src/error.rs index 3590f4c4..985aaf6e 100644 --- a/odbc-api/src/error.rs +++ b/odbc-api/src/error.rs @@ -41,9 +41,10 @@ pub enum Error { AbortedConnectionStringCompletion, /// An error returned if we fail to set the ODBC version #[error( - "ODBC diver manager does not seem to support the required ODBC version 3.80. (Most \ - likely you need to update unixODBC if you run on a Linux. Diagnostic record returned by \ - SQLSetEnvAttr:\n{0}" + "The ODBC diver manager installed in your system does not seem to support ODBC API version + 3.80. Which is required by this application. Most likely you need to update your driver + manager. Your driver manager is most likely unixODBC if you run on a Linux. Diagnostic + record returned by SQLSetEnvAttr:\n{0}" )] UnsupportedOdbcApiVersion(DiagnosticRecord), /// An error emitted by an `std::io::ReadBuf` implementation used as an input argument. diff --git a/odbcsv/Cargo.toml b/odbcsv/Cargo.toml index bc55392e..3d7b71fb 100644 --- a/odbcsv/Cargo.toml +++ b/odbcsv/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "odbcsv" -version = "0.3.65" +version = "0.3.66" authors = ["Markus Klein"] edition = "2021" license = "MIT" @@ -29,7 +29,7 @@ readme = "Readme.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -odbc-api = { version = "0.36.0", path = "../odbc-api" } +odbc-api = { version = "0.36.1", path = "../odbc-api" } csv = "1.1.6" anyhow = "1.0.56" stderrlog = "0.5.1" diff --git a/odbcsv/Changelog.md b/odbcsv/Changelog.md index d9bd7818..be8d2c63 100644 --- a/odbcsv/Changelog.md +++ b/odbcsv/Changelog.md @@ -1,5 +1,9 @@ # Changelog +## 0.3.66 + +* Updated dependencies + ## 0.3.65 * Updated dependencies