Skip to content

Commit ff20a31

Browse files
committed
feat: StatementImpl and StatementRef are now Send
1 parent dbbb72e commit ff20a31

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

odbc-api/src/handles/statement.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,15 @@ impl StatementImpl<'_> {
9595
}
9696
}
9797

98+
/// According to the ODBC documentation this is safe. See:
99+
/// <https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/multithreading>
100+
///
101+
/// We maybe could consider a statement to be `Sync` as well, since all operations on it currently
102+
/// require `&mut self`. Yet maybe we get forced to allow some of these operations to take `&self`
103+
/// in the future, like we do for [`crate::Connection`] to allow for shared ownership of
104+
/// connections by multiple statements.
105+
unsafe impl Send for StatementImpl<'_> {}
106+
98107
/// A borrowed valid (i.e. successfully allocated) ODBC statement handle. This can be used instead
99108
/// of a mutable reference to a [`StatementImpl`]. The main advantage here is that the lifetime
100109
/// paramater remains covariant, whereas if we would just take a mutable reference to an owned
@@ -130,6 +139,15 @@ unsafe impl AnyHandle for StatementRef<'_> {
130139
}
131140
}
132141

142+
/// According to the ODBC documentation this is safe. See:
143+
/// <https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/multithreading>
144+
///
145+
/// We maybe could consider a statement to be `Sync` as well, since all operations on it currently
146+
/// require `&mut self`. Yet maybe we get forced to allow some of these operations to take `&self`
147+
/// in the future, like we do for [`crate::Connection`] to allow for shared ownership of
148+
/// connections by multiple statements.
149+
unsafe impl Send for StatementRef<'_> {}
150+
133151
/// Allows us to be generic over the ownership type (mutably borrowed or owned) of a statement
134152
pub trait AsStatementRef {
135153
/// Get an exclusive reference to the underlying statement handle. This method is used to

0 commit comments

Comments
 (0)