Skip to content

Commit ba7da61

Browse files
committed
refactor(plugin-mssql): drain results and log TEXTSIZE failures on connect
1 parent 2de97de commit ba7da61

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2323
- Switching between sidebar tables no longer leaves extra blank space above the list. (#1675)
2424
- SSH tunnels no longer pin a CPU core after the connection drops. A dropped tunnel is now detected and torn down instead of spinning in its relay loop. (#1769)
2525
- Restored table tabs now load with the current page size instead of the page size from the previous session.
26+
- MSSQL: large `nvarchar(max)` and `text` values no longer truncate to 2048 bytes when copied or viewed. TEXTSIZE is raised at connect time. (#1783)
2627

2728
## [0.53.0] - 2026-06-25
2829

Plugins/MSSQLDriverPlugin/FreeTDSConnection.swift

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,20 @@ nonisolated final class FreeTDSConnection: @unchecked Sendable {
180180
_isConnected = true
181181
lock.unlock()
182182

183-
// FreeTDS default TEXTSIZE is 2048. Set to 2 GB so nvarchar(max)/text columns return in full.
184-
_ = dbcmd(proc, "SET TEXTSIZE 2147483647")
185-
_ = dbsqlexec(proc)
186-
_ = dbresults(proc)
183+
applyMaxTextSize(proc)
184+
}
185+
186+
private func applyMaxTextSize(_ proc: UnsafeMutablePointer<DBPROCESS>) {
187+
guard dbcmd(proc, "SET TEXTSIZE \(Int32.max)") != FAIL, dbsqlexec(proc) != FAIL else {
188+
freetdsLogger.error("Failed to raise TEXTSIZE; large text columns may be truncated to the 2048-byte default")
189+
return
190+
}
191+
while true {
192+
let resCode = dbresults(proc)
193+
if resCode == FAIL || resCode == Int32(NO_MORE_RESULTS) {
194+
break
195+
}
196+
}
187197
}
188198

189199
func switchDatabase(_ database: String) async throws {

0 commit comments

Comments
 (0)