Skip to content

Commit 07e7df4

Browse files
committed
fix: resolve deadlock, dead code, system keyspace filter, and EXPLAIN handling
1 parent e5e433f commit 07e7df4

2 files changed

Lines changed: 9 additions & 17 deletions

File tree

Plugins/CassandraDriverPlugin/CassandraPlugin.swift

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -718,13 +718,9 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen
718718
}
719719

720720
func disconnect() {
721-
let actor = connectionActor
722-
let semaphore = DispatchSemaphore(value: 0)
723-
Task {
724-
await actor.close()
725-
semaphore.signal()
721+
Task.detached(priority: .utility) { [connectionActor] in
722+
await connectionActor.close()
726723
}
727-
semaphore.wait()
728724
stateLock.lock()
729725
_currentKeyspace = nil
730726
_cachedVersion = nil
@@ -1004,9 +1000,6 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen
10041000

10051001
func fetchTableMetadata(table: String, schema: String?) async throws -> PluginTableMetadata {
10061002
let ks = resolveKeyspace(schema)
1007-
let safeTable = escapeSingleQuote(table)
1008-
let safeKs = escapeSingleQuote(ks)
1009-
10101003
// Cassandra doesn't have a cheap row count — use a bounded count
10111004
let countQuery = "SELECT COUNT(*) FROM \"\(escapeIdentifier(ks))\".\"\(escapeIdentifier(table))\" LIMIT 100001"
10121005
let countResult = try? await execute(query: countQuery)
@@ -1027,8 +1020,12 @@ internal final class CassandraPluginDriver: PluginDatabaseDriver, @unchecked Sen
10271020
func fetchDatabases() async throws -> [String] {
10281021
let query = "SELECT keyspace_name FROM system_schema.keyspaces"
10291022
let result = try await execute(query: query)
1023+
let systemKeyspaces: Set<String> = [
1024+
"system", "system_schema", "system_auth",
1025+
"system_distributed", "system_traces", "system_virtual_schema",
1026+
]
10301027
return result.rows.compactMap { $0[safe: 0] ?? nil }
1031-
.filter { !$0.hasPrefix("system") }
1028+
.filter { !systemKeyspaces.contains($0) }
10321029
.sorted()
10331030
}
10341031

TablePro/Views/Main/MainContentCoordinator.swift

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -708,19 +708,14 @@ final class MainContentCoordinator {
708708
return
709709
}
710710

711-
// Cassandra/ScyllaDB don't support EXPLAIN
712-
if connection.type == .cassandra || connection.type == .scylladb {
711+
guard let adapter = DatabaseManager.shared.driver(for: connectionId) as? PluginDriverAdapter,
712+
let explainSQL = adapter.buildExplainQuery(stmt) else {
713713
if let index = tabManager.selectedTabIndex {
714714
tabManager.tabs[index].errorMessage = String(localized: "EXPLAIN is not supported for this database type.")
715715
}
716716
return
717717
}
718718

719-
guard let adapter = DatabaseManager.shared.driver(for: connectionId) as? PluginDriverAdapter,
720-
let explainSQL = adapter.buildExplainQuery(stmt) else {
721-
return
722-
}
723-
724719
if needsConfirmation {
725720
Task { @MainActor in
726721
let window = NSApp.keyWindow

0 commit comments

Comments
 (0)