Skip to content

Commit

Permalink
improve error message then setting odbc version
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Mar 25, 2022
1 parent d31ed7a commit f5ee510
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 17 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions odbc-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "odbc-api"
version = "0.36.0"
version = "0.36.1"
authors = ["Markus Klein"]
edition = "2021"
license = "MIT"
Expand Down Expand Up @@ -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"
12 changes: 8 additions & 4 deletions odbc-api/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions odbc-api/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions odbcsv/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "odbcsv"
version = "0.3.65"
version = "0.3.66"
authors = ["Markus Klein"]
edition = "2021"
license = "MIT"
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions odbcsv/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 0.3.66

* Updated dependencies

## 0.3.65

* Updated dependencies
Expand Down

0 comments on commit f5ee510

Please sign in to comment.