Skip to content

Commit

Permalink
Fix list attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed Jan 29, 2024
1 parent 2823471 commit d9da836
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 14 deletions.
4 changes: 2 additions & 2 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

## 6.0.1

* Fixes an issue with `Environment::drivers`, which caused it to have at most one driver attribute in the `DriverInfo` attributes.

## 6.0.0

* `ConcurrentBlockCursor::from_block_cursor` is now infalliable.
Expand Down
2 changes: 1 addition & 1 deletion odbc-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "odbc-api"
version = "6.0.0"
version = "6.0.1"
authors = ["Markus Klein"]
edition = "2021"
license = "MIT"
Expand Down
18 changes: 10 additions & 8 deletions odbc-api/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ use std::{cmp::max, collections::HashMap, ptr::null_mut, sync::Mutex};
use crate::{
connection::ConnectionOptions,
error::ExtendResult,
handles::{self, log_diagnostics, OutputStringBuffer, SqlResult, SqlText, State, SzBuffer},
handles::{
self, log_diagnostics, slice_to_utf8, OutputStringBuffer, SqlChar, SqlResult, SqlText,
State, SzBuffer,
},
Connection, DriverCompleteOption, Error,
};
use log::debug;
Expand Down Expand Up @@ -506,19 +509,18 @@ impl Environment {

// Allocate +1 character extra for terminating zero
let mut desc_buf = SzBuffer::with_capacity(desc_len as usize);
let mut attr_buf = SzBuffer::with_capacity(attr_len as usize);
// Do **not** use nul terminated buffer, as nul is used to delimit key value pairs of
// attributes.
let mut attr_buf: Vec<SqlChar> = vec![0; attr_len as usize];

while self
.environment
.drivers_buffer_fill(
FetchOrientation::Next,
desc_buf.mut_buf(),
attr_buf.mut_buf(),
)
.drivers_buffer_fill(FetchOrientation::Next, desc_buf.mut_buf(), &mut attr_buf)
.into_result_bool(&self.environment)?
{
let description = desc_buf.to_utf8();
let attributes = attr_buf.to_utf8();
let attributes =
slice_to_utf8(&attr_buf).expect("Attributes must be interpretable as UTF-8");

let attributes = attributes_iter(&attributes).collect();

Expand Down
1 change: 0 additions & 1 deletion odbc-api/tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4317,7 +4317,6 @@ fn concurrent_fetch_skip_first_result_set(profile: &Profile) {
/// <https://github.com/pacman82/odbc-api/issues/511>) in which we used a buffer intended for zero
/// terminated strings to get the attributes. Yet the attributes use the `0` as a delimiter.
#[test]
#[should_panic] // Bug not fixed yet
fn list_all_driver_attributes() {
// Given an ODBC environment with drivers installed
let environment = &ENV;
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 = "1.0.4"
version = "1.0.5"
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 = "6.0.0", path = "../odbc-api" }
odbc-api = { version = "6.0.1", path = "../odbc-api" }
csv = "1.3.0"
anyhow = "1.0.79"
stderrlog = "0.5.4"
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

## 1.0.5

* Fixes an issue causing `list-drivers` subcommand to only list one attribute. Now all attributes are listed.

## 1.0.4

* Updated dependencies
Expand Down

0 comments on commit d9da836

Please sign in to comment.