From e85dbe69e37065ec76e701d4b3d26a7cb175701f Mon Sep 17 00:00:00 2001 From: Markus Klein Date: Sat, 1 May 2021 15:56:02 +0200 Subject: [PATCH] add DATA_AT_EXEC --- Cargo.toml | 2 +- Changelog.md | 6 ++++++ src/functions.rs | 20 ++++++++++++++++---- src/indicator.rs | 22 ++++++++++++++++++++++ src/lib.rs | 8 +++----- 5 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 src/indicator.rs diff --git a/Cargo.toml b/Cargo.toml index e5827ee..b716f38 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "odbc-sys" -version = "0.18.0" +version = "0.18.1" authors = ["Markus Klein "] license = "MIT" description = "ODBC ffi bindings" diff --git a/Changelog.md b/Changelog.md index 1fe5c22..f0c0119 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,6 +1,12 @@ Changelog ========= +0.18.1 +------ + +* Add `DATA_AT_EXEC` +* Add `fn len_data_at_exec` + 0.18.0 ------ diff --git a/src/functions.rs b/src/functions.rs index bdb592f..97a964d 100644 --- a/src/functions.rs +++ b/src/functions.rs @@ -7,10 +7,22 @@ use crate::{ // static linking is not currently supported here for windows #[cfg_attr(windows, link(name = "odbc32"))] -#[cfg_attr(all(not(windows), not(feature = "static"), not(feature = "iodbc")), link(name = "odbc"))] -#[cfg_attr(all(not(windows), feature = "static", not(feature = "iodbc")), link(name = "odbc", kind = "static"))] -#[cfg_attr(all(not(windows), not(feature = "static"), feature = "iodbc"), link(name = "iodbc"))] -#[cfg_attr(all(not(windows), feature = "static", feature = "iodbc"), link(name = "iodbc", kind = "static"))] +#[cfg_attr( + all(not(windows), not(feature = "static"), not(feature = "iodbc")), + link(name = "odbc") +)] +#[cfg_attr( + all(not(windows), feature = "static", not(feature = "iodbc")), + link(name = "odbc", kind = "static") +)] +#[cfg_attr( + all(not(windows), not(feature = "static"), feature = "iodbc"), + link(name = "iodbc") +)] +#[cfg_attr( + all(not(windows), feature = "static", feature = "iodbc"), + link(name = "iodbc", kind = "static") +)] extern "system" { /// Allocates an environment, connection, statement, or descriptor handle. /// diff --git a/src/indicator.rs b/src/indicator.rs new file mode 100644 index 0000000..69e2766 --- /dev/null +++ b/src/indicator.rs @@ -0,0 +1,22 @@ +//! Special indicator values +use crate::Len; + +/// Indicates `NULL` values. +pub const NULL_DATA: Len = -1; + +/// Indicates that the size of the value is not known. ODBC returns this value in indicator buffers +/// for truncated values of unknown size. +pub const NO_TOTAL: Len = -4; + +/// Use this as the indicator argument to `SQLBindParameter` in order to indicate that the data is +/// send at statement execution time. +pub const DATA_AT_EXEC: Len = -2; + +/// Use result as the indicator argument to `SQLBindParameter` in order to indicate that the data is +/// send at statement execution time. In contrast to `DATA_AT_EXEC` the total size is passed to the +/// driver manager. +pub fn len_data_at_exec(length: Len) -> Len { + const SQL_LEN_DATA_AT_EXEC_OFFSET: Len = -100; + + -(length) + SQL_LEN_DATA_AT_EXEC_OFFSET +} diff --git a/src/lib.rs b/src/lib.rs index e443815..41a9616 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,8 @@ pub use self::{ attributes::*, bulk_operation::*, c_data_type::*, desc::*, fetch_orientation::*, functions::*, - info_type::*, interval::*, nullability::*, param_type::*, sql_data_type::*, sqlreturn::*, + indicator::*, info_type::*, interval::*, nullability::*, param_type::*, sql_data_type::*, + sqlreturn::*, }; use std::os::raw::{c_int, c_void}; @@ -20,6 +21,7 @@ mod c_data_type; mod desc; mod fetch_orientation; mod functions; +mod indicator; mod info_type; mod interval; mod nullability; @@ -72,10 +74,6 @@ pub const MAX_MESSAGE_LENGTH: SmallInt = 512; pub const SQLSTATE_SIZE: usize = 5; pub const SQLSTATE_SIZEW: usize = 10; -// Special SQLGetData indicator values -pub const NULL_DATA: Len = -1; -pub const NO_TOTAL: Len = -4; - /// SQL Free Statement options #[repr(u16)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]