diff --git a/Cargo.lock b/Cargo.lock index 9bcf4e2..1721905 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,7 +32,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ef6978589202a00cd7e118380c448a08b6ed394c3a8df3a430d0898e3a42d046" dependencies = [ "android-properties", - "bitflags 2.5.0", + "bitflags 2.6.0", "cc", "cesu8", "jni", @@ -218,7 +218,7 @@ version = "52.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32aae6a60458a2389c0da89c9de0b7932427776127da1a738e2efc21d32f3393" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", ] [[package]] @@ -287,9 +287,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.5.0" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" [[package]] name = "block2" @@ -318,7 +318,7 @@ version = "0.12.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fba7adb4dd5aa98e5553510223000e7148f621165ec5f9acd7113f6ca4995298" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "log", "polling", "rustix", @@ -746,7 +746,7 @@ version = "0.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "libc", "redox_syscall", ] @@ -775,7 +775,7 @@ version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "jni-sys", "log", "ndk-sys", @@ -916,7 +916,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "libc", "objc2", @@ -932,7 +932,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-core-location", @@ -956,7 +956,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-foundation", @@ -998,7 +998,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "dispatch", "libc", @@ -1023,7 +1023,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-foundation", @@ -1035,7 +1035,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-foundation", @@ -1058,7 +1058,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-cloud-kit", @@ -1090,7 +1090,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "objc2", "objc2-core-location", @@ -1250,7 +1250,7 @@ version = "0.38.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "errno", "libc", "linux-raw-sys", @@ -1712,7 +1712,7 @@ checksum = "49f45a7b7e2de6af35448d7718dab6d95acec466eb3bb7a56f4d31d1af754004" dependencies = [ "android-activity", "atomic-waker", - "bitflags 2.5.0", + "bitflags 2.6.0", "block2", "calloop", "cfg_aliases", @@ -1759,7 +1759,7 @@ version = "0.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" dependencies = [ - "bitflags 2.5.0", + "bitflags 2.6.0", "dlib", "log", "once_cell", diff --git a/src/reader.rs b/src/reader.rs index 7583157..8c9b5f7 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -73,12 +73,8 @@ pub unsafe extern "C" fn arrow_odbc_reader_make( let dbms_name = try_!(connection.0.database_management_system_name()); debug!("Database managment system name as reported by ODBC: {dbms_name}"); - let maybe_cursor = try_!(connection.0.into_cursor(query, ¶meters[..])); - let reader = if let Some(cursor) = maybe_cursor { - ArrowOdbcReader::new(cursor) - } else { - ArrowOdbcReader::empty() - }; + let mut reader = ArrowOdbcReader::new(connection.0); + try_!(reader.promote_to_cursor(query, ¶meters[..])); *reader_out = Box::into_raw(Box::new(reader)); null_mut() // Ok(()) } diff --git a/src/reader/arrow_odbc_reader.rs b/src/reader/arrow_odbc_reader.rs index 67e8d65..b560bfe 100644 --- a/src/reader/arrow_odbc_reader.rs +++ b/src/reader/arrow_odbc_reader.rs @@ -46,9 +46,9 @@ pub enum ArrowOdbcReader { } impl ArrowOdbcReader { - /// Creates a new reader in Cursor state. - pub fn new(cursor: CursorImpl>) -> Self { - Self::Cursor(cursor) + /// Creates a new reader in Connection state. + pub fn new(connection: Connection<'static>) -> Self { + Self::Connection(connection) } pub fn empty() -> Self { @@ -108,8 +108,8 @@ impl ArrowOdbcReader { *self = ArrowOdbcReader::Connection(connection) } - /// Promote Connection to cursor state. If this operation fails, the reader will be in empty - /// state. + /// Promote Connection to cursor state. If this operation fails, the reader will stay in + /// connection state. pub fn promote_to_cursor(&mut self, query: &str, params: impl ParameterCollectionRef) -> Result<(), ArrowOdbcError> { // Move self into a temporary instance we own, in order to take ownership of the inner // reader and move it to a different state. @@ -125,8 +125,15 @@ impl ArrowOdbcReader { } }; - if let Some(cursor) = conn.into_cursor(query, params)? { - *self = ArrowOdbcReader::Cursor(cursor); + match conn.into_cursor(query, params) { + Ok(None) => (), + Ok(Some(cursor)) => { + *self = ArrowOdbcReader::Cursor(cursor); + }, + Err(error) => { + *self = ArrowOdbcReader::Connection(error.connection); + return Err(error.error.into()) + }, } Ok(()) }