mod any_handle;
mod bind;
mod buffer;
mod column_description;
mod connection;
mod data_type;
mod descriptor;
mod diagnostics;
mod environment;
mod logging;
mod sql_char;
mod sql_result;
mod statement;
mod statement_connection;
pub use self::{
any_handle::AnyHandle,
bind::{CData, CDataMut, DelayedInput, HasDataType},
column_description::{ColumnDescription, Nullability},
connection::Connection,
data_type::DataType,
descriptor::Descriptor,
diagnostics::{DiagnosticResult, DiagnosticStream, Diagnostics, Record, State},
environment::Environment,
logging::{log_diagnostic_record, log_diagnostics},
sql_char::{OutputStringBuffer, SqlChar, SqlText, SzBuffer, slice_to_cow_utf8, slice_to_utf8},
sql_result::SqlResult,
statement::{AsStatementRef, ColumnType, Statement, StatementImpl, StatementRef},
statement_connection::{StatementConnection, StatementParent},
};
#[allow(deprecated)]
pub use self::statement::ParameterDescription;
pub(crate) use self::data_type::{ASSUMED_MAX_LENGTH_OF_VARCHAR, ASSUMED_MAX_LENGTH_OF_W_VARCHAR};
use log::debug;
use odbc_sys::{Handle, HandleType, SQLFreeHandle, SqlReturn};
use std::thread::panicking;
pub unsafe fn drop_handle(handle: Handle, handle_type: HandleType) {
match unsafe { SQLFreeHandle(handle_type, handle) } {
SqlReturn::SUCCESS => {
#[cfg(not(feature = "structured_logging"))]
debug!("SQLFreeHandle dropped {handle:?} of type {handle_type:?}.");
#[cfg(feature = "structured_logging")]
debug!(
target: "odbc_api",
handle:? = handle,
handle_type:? = handle_type;
"ODBC handle freed"
);
}
other => {
if !panicking() {
panic!("SQLFreeHandle failed with error code: {:?}", other.0)
}
}
}
}