Skip to content

Commit dbbb72e

Browse files
committed
chore: Update to odbc-sys 26
1 parent 1dc5aba commit dbbb72e

File tree

8 files changed

+345
-238
lines changed

8 files changed

+345
-238
lines changed

Cargo.lock

Lines changed: 315 additions & 209 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

odbc-api/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ prompt = ["dep:winit"]
9393

9494
[dependencies]
9595
# Low level bindings to ODBC API calls into libodbc.so
96-
odbc-sys = { version = "0.25", default-features = false }
96+
odbc-sys = { version = "0.26", default-features = false }
9797
# Used to generate code for the error type
9898
thiserror = "2.0.16"
9999
# Used as a log frontend to emit log messages for applications

odbc-api/src/handles/connection.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ use super::{
1212
};
1313
use log::debug;
1414
use odbc_sys::{
15-
CompletionType, ConnectionAttribute, DriverConnectOption, HDbc, HEnv, HStmt, HWnd, Handle,
16-
HandleType, IS_UINTEGER, InfoType, Pointer, SQLAllocHandle, SQLDisconnect, SQLEndTran,
15+
CompletionType, ConnectionAttribute, DriverConnectOption, HDbc, HEnv, HWnd, Handle, HandleType,
16+
IS_UINTEGER, InfoType, Pointer, SQLAllocHandle, SQLDisconnect, SQLEndTran,
1717
};
1818
use std::{ffi::c_void, marker::PhantomData, mem::size_of, ptr::null_mut};
1919

@@ -44,7 +44,7 @@ pub struct Connection<'c> {
4444

4545
unsafe impl AnyHandle for Connection<'_> {
4646
fn as_handle(&self) -> Handle {
47-
self.handle as Handle
47+
self.handle.as_handle()
4848
}
4949

5050
fn handle_type(&self) -> HandleType {
@@ -55,7 +55,7 @@ unsafe impl AnyHandle for Connection<'_> {
5555
impl Drop for Connection<'_> {
5656
fn drop(&mut self) {
5757
unsafe {
58-
drop_handle(self.handle as Handle, HandleType::Dbc);
58+
drop_handle(self.handle.as_handle(), HandleType::Dbc);
5959
}
6060
}
6161
}
@@ -195,11 +195,11 @@ impl Connection<'_> {
195195

196196
/// Allocate a new statement handle. The `Statement` must not outlive the `Connection`.
197197
pub fn allocate_statement(&self) -> SqlResult<StatementImpl<'_>> {
198-
let mut out = null_mut();
198+
let mut out = Handle::null();
199199
unsafe {
200200
SQLAllocHandle(HandleType::Stmt, self.as_handle(), &mut out)
201201
.into_sql_result("SQLAllocHandle")
202-
.on_success(|| StatementImpl::new(out as HStmt))
202+
.on_success(|| StatementImpl::new(out.as_hstmt()))
203203
}
204204
}
205205

odbc-api/src/handles/descriptor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl Descriptor<'_> {
115115

116116
unsafe impl AnyHandle for Descriptor<'_> {
117117
fn as_handle(&self) -> Handle {
118-
self.handle as Handle
118+
self.handle.as_handle()
119119
}
120120

121121
fn handle_type(&self) -> HandleType {

odbc-api/src/handles/environment.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use super::{
77
};
88
use log::debug;
99
use odbc_sys::{
10-
AttrCpMatch, AttrOdbcVersion, EnvironmentAttribute, FetchOrientation, HDbc, HEnv, Handle,
11-
HandleType, SQLAllocHandle, SQLSetEnvAttr,
10+
AttrCpMatch, AttrOdbcVersion, EnvironmentAttribute, FetchOrientation, HEnv, Handle, HandleType,
11+
SQLAllocHandle, SQLSetEnvAttr,
1212
};
1313
use std::ptr::null_mut;
1414

@@ -40,7 +40,7 @@ unsafe impl Send for Environment {}
4040

4141
unsafe impl AnyHandle for Environment {
4242
fn as_handle(&self) -> Handle {
43-
self.handle as Handle
43+
self.handle.as_handle()
4444
}
4545

4646
fn handle_type(&self) -> HandleType {
@@ -51,7 +51,7 @@ unsafe impl AnyHandle for Environment {
5151
impl Drop for Environment {
5252
fn drop(&mut self) {
5353
unsafe {
54-
drop_handle(self.handle as Handle, HandleType::Env);
54+
drop_handle(self.handle.as_handle(), HandleType::Env);
5555
}
5656
}
5757
}
@@ -72,7 +72,7 @@ impl Environment {
7272
pub unsafe fn set_connection_pooling(scheme: odbc_sys::AttrConnectionPooling) -> SqlResult<()> {
7373
unsafe {
7474
SQLSetEnvAttr(
75-
null_mut(),
75+
HEnv::null(),
7676
odbc_sys::EnvironmentAttribute::ConnectionPooling,
7777
scheme.into(),
7878
odbc_sys::IS_INTEGER,
@@ -103,11 +103,12 @@ impl Environment {
103103
// however official sources imply it is ok for an application to have multiple environments
104104
// and I did not get it to race ever on my machine.
105105
unsafe {
106-
let mut handle = null_mut();
107-
let result: SqlResult<()> = SQLAllocHandle(HandleType::Env, null_mut(), &mut handle)
108-
.into_sql_result("SQLAllocHandle");
106+
let mut handle = Handle::null();
107+
let result: SqlResult<()> =
108+
SQLAllocHandle(HandleType::Env, Handle::null(), &mut handle)
109+
.into_sql_result("SQLAllocHandle");
109110
result.on_success(|| Environment {
110-
handle: handle as HEnv,
111+
handle: handle.as_henv(),
111112
})
112113
}
113114
}
@@ -128,12 +129,12 @@ impl Environment {
128129

129130
/// Allocate a new connection handle. The `Connection` must not outlive the `Environment`.
130131
pub fn allocate_connection(&self) -> SqlResult<Connection<'_>> {
131-
let mut handle = null_mut();
132+
let mut handle = Handle::null();
132133
unsafe {
133134
SQLAllocHandle(HandleType::Dbc, self.as_handle(), &mut handle)
134135
.into_sql_result("SQLAllocHandle")
135136
.on_success(|| {
136-
let handle = handle as HDbc;
137+
let handle = handle.as_hdbc();
137138
debug!("SQLAllocHandle allocated connection (Dbc) handle '{handle:?}'");
138139
Connection::new(handle)
139140
})

odbc-api/src/handles/statement.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use super::{
1111
};
1212
use log::debug;
1313
use odbc_sys::{
14-
Desc, FreeStmtOption, HDbc, HStmt, Handle, HandleType, IS_POINTER, Len, ParamType, Pointer,
15-
SQLBindCol, SQLBindParameter, SQLCloseCursor, SQLDescribeParam, SQLExecute, SQLFetch,
14+
Desc, FreeStmtOption, HDbc, HDesc, HStmt, Handle, HandleType, IS_POINTER, Len, ParamType,
15+
Pointer, SQLBindCol, SQLBindParameter, SQLCloseCursor, SQLDescribeParam, SQLExecute, SQLFetch,
1616
SQLFreeStmt, SQLGetData, SQLMoreResults, SQLNumParams, SQLNumResultCols, SQLParamData,
1717
SQLPutData, SQLRowCount, SqlDataType, SqlReturn, StatementAttribute,
1818
};
@@ -51,7 +51,7 @@ pub struct StatementImpl<'s> {
5151

5252
unsafe impl AnyHandle for StatementImpl<'_> {
5353
fn as_handle(&self) -> Handle {
54-
self.handle as Handle
54+
self.handle.as_handle()
5555
}
5656

5757
fn handle_type(&self) -> HandleType {
@@ -62,7 +62,7 @@ unsafe impl AnyHandle for StatementImpl<'_> {
6262
impl Drop for StatementImpl<'_> {
6363
fn drop(&mut self) {
6464
unsafe {
65-
drop_handle(self.handle as Handle, HandleType::Stmt);
65+
drop_handle(self.handle.as_handle(), HandleType::Stmt);
6666
}
6767
}
6868
}
@@ -122,7 +122,7 @@ impl Statement for StatementRef<'_> {
122122

123123
unsafe impl AnyHandle for StatementRef<'_> {
124124
fn as_handle(&self) -> Handle {
125-
self.handle as Handle
125+
self.handle.as_handle()
126126
}
127127

128128
fn handle_type(&self) -> HandleType {
@@ -1053,8 +1053,8 @@ pub trait Statement: AnyHandle {
10531053
/// though.
10541054
fn application_row_descriptor(&mut self) -> SqlResult<Descriptor<'_>> {
10551055
unsafe {
1056-
let mut hdesc: odbc_sys::HDesc = null_mut();
1057-
let hdesc_out = &mut hdesc as *mut odbc_sys::HDesc as Pointer;
1056+
let mut hdesc = HDesc::null();
1057+
let hdesc_out = &mut hdesc as *mut HDesc as Pointer;
10581058
odbc_sys::SQLGetStmtAttr(
10591059
self.as_sys(),
10601060
odbc_sys::StatementAttribute::AppRowDesc,

odbc-api/src/handles/statement_connection.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ where
3333
impl<C> Drop for StatementConnection<C> {
3434
fn drop(&mut self) {
3535
unsafe {
36-
drop_handle(self.handle as Handle, HandleType::Stmt);
36+
drop_handle(self.handle.as_handle(), HandleType::Stmt);
3737
}
3838
}
3939
}
@@ -62,7 +62,7 @@ where
6262
C: StatementParent,
6363
{
6464
fn as_handle(&self) -> Handle {
65-
self.handle as Handle
65+
self.handle.as_handle()
6666
}
6767

6868
fn handle_type(&self) -> HandleType {

odbc-api/tests/integration.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3969,7 +3969,7 @@ fn escape_hatch(profile: &Profile) {
39693969
// If we use `.into_sys` we need to drop the handle manually
39703970
let hstmt = statement.into_sys();
39713971
unsafe {
3972-
let ret = sys::SQLFreeHandle(sys::HandleType::Stmt, hstmt as sys::Handle);
3972+
let ret = sys::SQLFreeHandle(sys::HandleType::Stmt, hstmt.as_handle());
39733973
assert_eq!(ret, sys::SqlReturn::SUCCESS);
39743974
}
39753975
}

0 commit comments

Comments
 (0)