Skip to content

Migrate SQL Server driver from tiberius to mssql-tiberius-bridge#170

Merged
debba merged 3 commits into
TabularisDB:feat/sql-serverfrom
saurabh500:feat/bridge-migration
May 10, 2026
Merged

Migrate SQL Server driver from tiberius to mssql-tiberius-bridge#170
debba merged 3 commits into
TabularisDB:feat/sql-serverfrom
saurabh500:feat/bridge-migration

Conversation

@saurabh500
Copy link
Copy Markdown
Contributor

@saurabh500 saurabh500 commented May 8, 2026

Replaces the tiberius TDS driver with mssql-tiberius-bridge — a tiberius-compatible API facade over Microsoft's official mssql-tds Rust implementation.

Closes #171

What changed

File Change
Cargo.toml tiberius + tokio-utilmssql-tiberius-bridge = "=0.1.0-preview.1" (crates.io)
pool.rs TiberiusManagerBridgeManager — custom deadpool Manager pooling bridge Client objects. Eliminates manual TcpStream + compat_write() boilerplate
pool_manager.rs Type alias updates (TiberiusManagerBridgeManager)
extract/mod.rs tiberius::ColumnType → bridge ColumnType, adjusted FromSql patterns
introspection.rs Connection type update, into_first_result() is now sync (no second .await)
mod.rs Pool type + result collection updates

What didn't change

  • All SQL queries — identical
  • version.rs, helpers.rs, extract/temporal.rs — pure functions, no driver deps
  • Frontend — zero changes

Why

  • tiberius is community-maintained with infrequent updates
  • mssql-tds is Microsoft's official, actively developed TDS implementation
  • The bridge preserves the same API surface (Client, Row, Config, query(), simple_query(), into_first_result(), FromSql/ToSql), making this a mechanical migration
  • Unlocks future support for JSON columns, Vector type (SQL Server 2025), and Azure AD auth

Test results

  • ✅ All 471 existing tests pass
  • cargo clippy — zero warnings
  • cargo check — clean

Known limitation

execute() returns 0 for DML — upstream mssql-tds doesn't expose DONE token row counts yet. No impact on Phase 1 (read-only). Tracked in mssql-tiberius-bridge#1.

saurabh500 added 2 commits May 8, 2026 19:19
Replace the tiberius crate with mssql-tiberius-bridge, which provides
a tiberius-compatible API surface (row.get/try_get, query, simple_query,
into_first_result, Config builder) on top of Microsoft's official
mssql-tds protocol implementation.

Key changes:

Cargo.toml:
- Replace tiberius + tokio-util deps with mssql-tiberius-bridge git dep
- tokio-util removed (no other drivers use compat)

pool.rs (complete rewrite):
- Replace TiberiusManager/TiberiusConnection with BridgeManager/BridgeConnection
- BridgeManager pools mssql_tiberius_bridge::Client objects directly
  (not raw TdsClient), so introspection code can use .query()/.simple_query()
- Config builder uses bridge's fluent API (host/port/database/authentication)

pool_manager.rs:
- Update imports and type aliases to use BridgeManager

extract/mod.rs:
- Replace tiberius::{ColumnType, Row, numeric::Numeric} with bridge types
- Update ColumnType variant names to match bridge enum:
  Bitn→Bit, Intn removed (bridge maps IntN→Int4), Floatn→Float8,
  Datetimen→Datetime, DatetimeOffsetn→DatetimeOffset, Daten→Date,
  Timen→Time, BigVarChar→Varchar, BigChar→Char, BigBinary→Binary,
  SSVariant→Ssvariant, Udt removed (not in bridge)
- Add Json/Vector/VarBinary coverage for new bridge column types
- Replace &[u8] with Vec<u8> for binary extraction (bridge FromSql)
- Remove Numeric fallback (bridge uses rust_decimal::Decimal directly)
- Remove read_intn helper (bridge resolves IntN at protocol level)

introspection.rs:
- Replace TiberiusConnection with BridgeConnection
- Replace tiberius::Row references with mssql_tiberius_bridge::Row
- Remove .await from .into_first_result() calls (bridge version is sync)

mod.rs:
- Update acquire() return type to use BridgeManager
- Fix Column field access: c.name() → c.name (bridge uses pub field)
- Remove .await from .into_first_result() calls

version.rs: No changes (pure module, no tiberius dependency)
Use published mssql-tiberius-bridge v0.1.0-preview.1 from crates.io
instead of git dependency.
@saurabh500 saurabh500 changed the title Feat/bridge migration Migrate SQL Server driver from tiberius to mssql-tiberius-bridge May 8, 2026
@saurabh500 saurabh500 marked this pull request as ready for review May 8, 2026 23:19
@saurabh500
Copy link
Copy Markdown
Contributor Author

@debba This is ready for review

Breaking changes from preview.1 → preview.3:
- Column.name is now pub(crate): use name() getter
- Column.column_type is now pub(crate): use column_type() getter

Also picks up new features:
- Config::trust_cert_ca for CA pinning
- ToSql for Vec<u8>, &[u8], and chrono date/time types
- Config::readonly() for ApplicationIntent=ReadOnly
- AuthMethod::aad_token for Entra ID federated auth
- SSRP instance lookup when instance_name is set
- QueryResult::into_row_stream for streaming API
- Row PartialEq impl
- Named Pipes and Shared Memory transports
- MultiSubnetFailover support
- TDS 8.0 Strict encryption support
- IntN/FltN column type resolution fix
@debba debba merged commit 851bb8c into TabularisDB:feat/sql-server May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants