Skip to main content

connectorx/sources/mssql/
mod.rs

1//! Source implementation for SQL Server.
2//!
3//! Two backend implementations exist:
4//! - `src_mssql_tiberius`: `tiberius` + `bb8-tiberius`, the original
5//!   implementation.
6//! - `src_mssql_tds`: `mssql-tds`, Microsoft's own TDS client.
7//!
8//! Enabling exactly one of these two Cargo features picks that backend at
9//! compile time, with no runtime switch (and no cost of linking the other
10//! backend in). Enabling *both* (as the Python bindings do, so `cx.mssql_driver` can
11//! flip backends at runtime) links both in and dispatches through the
12//! [`MsSQLSource`] enum wrapper instead, selecting the active one via
13//! `active_driver` / `set_active_driver` (available only with both features).
14//!
15//! All three configurations compile against the same
16//! [`MsSQLTypeSystem`] and [`MsSQLSourceError`], so
17//! `MsSQLArrowTransport` (with `dst_arrow`) and everything above the source layer
18//! is unaffected by which backend(s) are active. See
19//! sfu-db/connector-x#942 for the migration plan.
20
21#[cfg(all(not(feature = "src_mssql_tiberius"), not(feature = "src_mssql_tds")))]
22compile_error!("MSSQL source requires either `src_mssql_tiberius` or `src_mssql_tds`");
23
24mod driver;
25mod errors;
26mod typesystem;
27
28#[cfg(all(feature = "src_mssql_tiberius", feature = "src_mssql_tds"))]
29mod dual_impl;
30#[cfg(feature = "src_mssql_tds")]
31mod tds_impl;
32#[cfg(feature = "src_mssql_tiberius")]
33mod tiberius_impl;
34
35pub use self::driver::MsSQLDriverKind;
36pub use self::errors::MsSQLSourceError;
37pub use self::typesystem::{FloatN, IntN, MsSQLTypeSystem};
38
39#[cfg(all(feature = "src_mssql_tiberius", feature = "src_mssql_tds"))]
40pub use self::driver::set_active_driver;
41
42/// Returns the MSSQL driver ConnectorX currently uses. Only meaningful (and
43/// only compiled in) when both `src_mssql_tiberius` and `src_mssql_tds` are
44/// enabled — otherwise there is exactly one backend and no switch to query.
45#[cfg(all(feature = "src_mssql_tiberius", feature = "src_mssql_tds"))]
46pub fn active_driver() -> MsSQLDriverKind {
47    self::driver::active_driver()
48}
49
50#[cfg(feature = "src_mssql_tiberius")]
51pub use self::tiberius_impl::mssql_config;
52#[cfg(all(feature = "src_mssql_tiberius", not(feature = "src_mssql_tds")))]
53pub use self::tiberius_impl::{MsSQLSource, MsSQLSourceParser, MsSQLSourcePartition};
54
55#[cfg(all(feature = "src_mssql_tds", not(feature = "src_mssql_tiberius")))]
56pub use self::tds_impl::{MsSQLSource, MsSQLSourceParser, MsSQLSourcePartition};
57
58#[cfg(all(feature = "src_mssql_tiberius", feature = "src_mssql_tds"))]
59pub use self::dual_impl::{MsSQLSource, MsSQLSourceParser, MsSQLSourcePartition};
60
61#[cfg(feature = "src_mssql_tds")]
62pub(crate) use self::tds_impl::tds_get_partition_range;