Skip to content

Commit

Permalink
add DATA_AT_EXEC
Browse files Browse the repository at this point in the history
  • Loading branch information
pacman82 committed May 1, 2021
1 parent cf22bab commit e85dbe6
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "odbc-sys"
version = "0.18.0"
version = "0.18.1"
authors = ["Markus Klein <markus-klein@live.de>"]
license = "MIT"
description = "ODBC ffi bindings"
Expand Down
6 changes: 6 additions & 0 deletions Changelog.md
@@ -1,6 +1,12 @@
Changelog
=========

0.18.1
------

* Add `DATA_AT_EXEC`
* Add `fn len_data_at_exec`

0.18.0
------

Expand Down
20 changes: 16 additions & 4 deletions src/functions.rs
Expand Up @@ -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.
///
Expand Down
22 changes: 22 additions & 0 deletions 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
}
8 changes: 3 additions & 5 deletions src/lib.rs
Expand Up @@ -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};

Expand All @@ -20,6 +21,7 @@ mod c_data_type;
mod desc;
mod fetch_orientation;
mod functions;
mod indicator;
mod info_type;
mod interval;
mod nullability;
Expand Down Expand Up @@ -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)]
Expand Down

0 comments on commit e85dbe6

Please sign in to comment.