Improved progress display

Previously, the progress bar updated only after completing an entire table.

For large tables such as LIBARC, this could make the application appear to have stopped responding.

Phase 10 updates the interface while rows are being exported.
This commit is contained in:
Mark Gregory
2026-10-16 22:46:01 +01:00
parent 5db95d7212
commit 8db8b30ed8
28 changed files with 287 additions and 280 deletions
-11
View File
@@ -1,11 +0,0 @@
# Phase 14 — MySQL Account Management
Adds a **Manage Accounts…** sheet under Administration → Users and Privileges.
Operations: create account, change password, lock/unlock account, grant/revoke an individual database privilege. Every operation displays a SQL preview and requires an explicit confirmation. Passwords are masked in previews, never persisted by the account management form, and cleared after execution. Privileges are chosen from an allowlist. User, host, and database inputs use conservative character allowlists.
The existing account list and Show Grants remain available. Auto-refresh is switched off when account management opens, and the account list refreshes on dismissal.
**Limitations:** Requires sufficient MySQL privileges. Only basic ASCII account/host/database names supported. No account deletion, global privileges, roles, or complex grant options. SQL mode NO_BACKSLASH_ESCAPES is rejected for password operations. Password values are sent using the native query protocol, which may expose them in server-side SQL logs; parameterized MySQL account DDL isn't implemented. No automatic rollback for account changes.
**Validation:** Static/source inspection and ZIP integrity only. This environment cannot compile the macOS Xcode target or verify changes against a MySQL server. Test on a disposable MySQL instance before production use.
-15
View File
@@ -1,15 +0,0 @@
# Phase 16 — Native MySQL Diagnostics
Adds five read-only Administration → Performance screens:
- **Slow Query Analysis:** `performance_schema.events_statements_summary_by_digest` sorted by cumulative execution time, with counts, rows examined, and first/last seen timestamps. Times are raw picoseconds, **not** milliseconds.
- **Table I/O Hotspots:** `performance_schema.table_io_waits_summary_by_table` with read/write counts and timings.
- **InnoDB Metrics:** selected `SHOW GLOBAL STATUS` buffer-pool, I/O, lock, and row counters.
- **InnoDB Lock Waits:** current edges in `performance_schema.data_lock_waits`.
- **Connection Statistics:** connection, abort, thread, and query counters.
All screens reuse the existing searchable grid, manual refresh, and optional five-second auto-refresh. SQL is read-only. Some screens require MySQL 8.0+ and enabled Performance Schema instrumentation/privileges; errors are displayed in the existing administration error view. The digest and table I/O summaries are cumulative and may be reset by server restarts or instrumentation changes. This phase does **not** enable slow-query logging or change server configuration.
## Validation
Source inspection and ZIP integrity check performed. **Not compiled with Xcode or tested on a live MySQL server.** Test on a nonproduction MySQL 8.0+ instance first.
-11
View File
@@ -1,11 +0,0 @@
# Phase 17 — SQL Editor Productivity
- Added persisted query execution history (latest 200 statements), including timestamp, connection, schema, success/failure, and error details. Schema-list refreshes are not recorded.
- Added History panel with filtering, reopen in a new tab, and clear history.
- Added a persistent saved SQL query library, with save, filter, open, and delete.
- Added AppKit SQL keyword completion via NSTextViewDelegate's standard completion interface (typically Esc or Option-Esc depending on macOS key bindings). Completions are keyword-based, not live schema-aware.
- Preserved the existing SQL syntax highlighting and query tab handling.
## Caveats
History and saved SQL are stored in local UserDefaults and may contain sensitive SQL text; avoid executing statements containing literal secrets if local history retention is a concern. Results remain subject to the existing protocol row cap. This phase has not been built in Xcode or tested against a live server.
-18
View File
@@ -1,18 +0,0 @@
# Phase 18 — SQL Editor and Result Grid
Built from the Phase 17 project archive and includes the correction for the Phase 17 `localizedCaseInsensitiveHasPrefix` compilation error.
## Changes
- Execute highlighted SQL independently of the complete editor buffer (Run Selection).
- SQL completion includes cached table and view names loaded in the Schemas navigator, alongside SQL keywords. Column-aware suggestions are not yet implemented.
- Case-insensitive local filtering of query result rows.
- Local result sorting by chosen column, ascending or descending.
- CSV export of the currently displayed rows, with RFC-style doubled quotes, UTF-8 BOM and CRLF line endings.
- Query elapsed wall-clock time, shown after execution completes (includes connection overhead).
## Limitations
- Result grid filters/sorts operate only on rows returned by the existing query engine, not the full database table.
- The CSV writer constructs the file in memory and should not be used for huge result sets.
- SQL autocomplete suggestions depend on schemas already loaded; no column metadata is fetched.
- No new SQL error underlining was added.
- Not compiled on macOS or tested against a MySQL server; run xcodebuild on the Mac.
+81 -3
View File
@@ -750,7 +750,20 @@ struct MainView: View {
}
private var sqlEditor: some View {
HStack(spacing: 0) {
VStack(spacing: 0) {
if model.status == "Error" && !model.result.message.isEmpty {
HStack(alignment: .top, spacing: 8) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(.red)
Text(model.result.message)
.font(.system(size: 11, design: .monospaced))
.textSelection(.enabled)
.frame(maxWidth: .infinity, alignment: .leading)
}
.padding(8)
.background(Color.red.opacity(0.09))
}
HStack(spacing: 0) {
if UserDefaults.standard.object(
forKey: "preferences.showLineNumbers"
) as? Bool ?? true {
@@ -767,7 +780,8 @@ struct MainView: View {
SQLTextView(text: $model.sql, selectedSQL: $selectedSQL, completions: Array(Set(model.schemaTables.values.flatMap { $0 } + model.schemaViews.values.flatMap { $0 } + (model.schemaColumns[model.selectedDatabase] ?? []))).sorted())
}
.background(Color(nsColor: .textBackgroundColor))
.background(Color(nsColor: .textBackgroundColor))
}
}
private var lineNumbers: some View {
@@ -1349,6 +1363,50 @@ private struct WorkbenchExplainView: View {
return value.trimmingCharacters(in: .whitespacesAndNewlines)
}
// Advisory analysis of the tabular EXPLAIN result. These are optimizer
// estimates, not measured execution statistics or automatic index DDL.
private var planInsights: [String] {
guard !useJSON, !plan.columns.isEmpty else { return [] }
let headings = plan.columns.map { $0.lowercased() }
func field(_ row: [String], _ name: String) -> String {
guard let index = headings.firstIndex(of: name), index < row.count else { return "" }
return row[index]
}
var messages: [String] = []
for row in plan.rows {
let table = field(row, "table")
let label = table.isEmpty ? "A query step" : "Table \(table)"
let access = field(row, "type").uppercased()
let key = field(row, "key")
let estimatedRows = field(row, "rows")
let extra = field(row, "extra").lowercased()
if access == "ALL" {
messages.append("\(label): full table scan (type=ALL). Check selectivity, predicates and available indexes before considering a new index.")
} else if access == "INDEX" {
messages.append("\(label): full index scan (type=index). This is not necessarily a problem for small tables or covering indexes.")
}
if key.isEmpty || key.uppercased() == "NULL" {
messages.append("\(label): no index selected for this step. An index is not always beneficial.")
}
if extra.contains("using temporary") {
messages.append("\(label): temporary table may be used for grouping, sorting or other operations.")
}
if extra.contains("using filesort") {
messages.append("\(label): additional sort operation indicated (Using filesort).")
}
if !estimatedRows.isEmpty, estimatedRows.uppercased() != "NULL" {
messages.append("\(label): optimizer estimates \(estimatedRows) rows examined for this step.")
}
}
return messages
}
private var copyablePlan: String {
if useJSON { return plan.rows.first?.first ?? "" }
return ([plan.columns.joined(separator: "\t")] + plan.rows.map { $0.joined(separator: "\t") })
.joined(separator: "\n")
}
private var eligible: Bool {
// Deliberately restrict this inspector to SELECT queries. EXPLAIN for
// UPDATE/DELETE is supported by MySQL but not offered here to keep
@@ -1385,6 +1443,11 @@ private struct WorkbenchExplainView: View {
.frame(width: 240)
Button("Run EXPLAIN") { Task { await loadPlan() } }
.disabled(isLoading || !eligible || model.selected == nil)
Button("Copy Plan") {
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(copyablePlan, forType: .string)
}
.disabled(plan.columns.isEmpty)
if isLoading { ProgressView().controlSize(.small) }
if let duration {
Text(String(format: "%.3f s", duration))
@@ -1413,7 +1476,22 @@ private struct WorkbenchExplainView: View {
} else {
ContentUnavailableView("No plan loaded", systemImage: "chart.bar.doc.horizontal")
}
Text("EXPLAIN shows estimates, not actual query execution times. The plan depends on the server's current statistics and configuration.")
if !planInsights.isEmpty {
DisclosureGroup("Plan observations (\(planInsights.count))") {
ScrollView {
VStack(alignment: .leading, spacing: 6) {
ForEach(Array(planInsights.enumerated()), id: \.offset) { _, observation in
Label(observation, systemImage: "info.circle")
.frame(maxWidth: .infinity, alignment: .leading)
}
}
.font(.callout)
.padding(.vertical, 6)
}
.frame(maxHeight: 160)
}
}
Text("EXPLAIN shows estimates, not actual query execution times. Observations are heuristics, not index recommendations. Confirm with representative data before changing production indexes.")
.font(.caption)
.foregroundStyle(.secondary)
}
@@ -27,3 +27,4 @@
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
/Volumes/Developer/Applications/WorkbenchReplacement/build/Build/Products/Debug/WorkbenchReplacement.app
@@ -19,7 +19,7 @@
<dict>
<key>cdhash</key>
<data>
gxPm9V32PbdbRR8yOyYXPS9q9hU=
PVnMv6+daaZqstZMQ+mKbqwrMxo=
</data>
<key>requirement</key>
<string>identifier "WorkbenchReplacement.debug" and anchor apple generic and certificate leaf[subject.CN] = "Apple Development: Mark Gregory (FLBRJ3BYDD)" and certificate 1[field.1.2.840.113635.100.6.2.1] /* exists */</string>
+42 -84
View File
@@ -90,90 +90,6 @@
<key>uniqueIdentifier</key>
<string>27B7943C-710F-4B49-802F-4D4346522832</string>
</dict>
<key>546596EB-C774-4242-A9D1-C86D46C7CAE8</key>
<dict>
<key>className</key>
<string>IDECommandLineBuildLog</string>
<key>documentTypeString</key>
<string>&lt;nil&gt;</string>
<key>domainType</key>
<string>Xcode.IDEActivityLogDomainType.BuildLog</string>
<key>fileName</key>
<string>546596EB-C774-4242-A9D1-C86D46C7CAE8.xcactivitylog</string>
<key>hasPrimaryLog</key>
<true/>
<key>primaryObservable</key>
<dict>
<key>highLevelStatus</key>
<string>S</string>
<key>totalNumberOfAnalyzerIssues</key>
<integer>0</integer>
<key>totalNumberOfErrors</key>
<integer>0</integer>
<key>totalNumberOfTestFailures</key>
<integer>0</integer>
<key>totalNumberOfWarnings</key>
<integer>0</integer>
</dict>
<key>schemeIdentifier-containerName</key>
<string>WorkbenchReplacement project</string>
<key>schemeIdentifier-schemeName</key>
<string>WorkbenchReplacement</string>
<key>schemeIdentifier-sharedScheme</key>
<integer>1</integer>
<key>signature</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>timeStartedRecording</key>
<real>813879115.19696796</real>
<key>timeStoppedRecording</key>
<real>813879130.83529198</real>
<key>title</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>uniqueIdentifier</key>
<string>546596EB-C774-4242-A9D1-C86D46C7CAE8</string>
</dict>
<key>67C568D7-BB93-4240-AB48-EF7CBFC85D9F</key>
<dict>
<key>className</key>
<string>IDECommandLineBuildLog</string>
<key>documentTypeString</key>
<string>&lt;nil&gt;</string>
<key>domainType</key>
<string>Xcode.IDEActivityLogDomainType.BuildLog</string>
<key>fileName</key>
<string>67C568D7-BB93-4240-AB48-EF7CBFC85D9F.xcactivitylog</string>
<key>hasPrimaryLog</key>
<true/>
<key>primaryObservable</key>
<dict>
<key>highLevelStatus</key>
<string>S</string>
<key>totalNumberOfAnalyzerIssues</key>
<integer>0</integer>
<key>totalNumberOfErrors</key>
<integer>0</integer>
<key>totalNumberOfTestFailures</key>
<integer>0</integer>
<key>totalNumberOfWarnings</key>
<integer>0</integer>
</dict>
<key>schemeIdentifier-containerName</key>
<string>WorkbenchReplacement project</string>
<key>schemeIdentifier-schemeName</key>
<string>WorkbenchReplacement</string>
<key>schemeIdentifier-sharedScheme</key>
<integer>1</integer>
<key>signature</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>timeStartedRecording</key>
<real>813879245.19600403</real>
<key>timeStoppedRecording</key>
<real>813879260.71434796</real>
<key>title</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>uniqueIdentifier</key>
<string>67C568D7-BB93-4240-AB48-EF7CBFC85D9F</string>
</dict>
<key>9B404BEF-D5CC-4B4B-93CF-3A0C95C748D2</key>
<dict>
<key>className</key>
@@ -258,6 +174,48 @@
<key>uniqueIdentifier</key>
<string>C0104C63-BBE9-4E40-811C-E7DC2E1277F6</string>
</dict>
<key>FE752EBA-0994-486D-9A0C-1DA5C49E3451</key>
<dict>
<key>className</key>
<string>IDECommandLineBuildLog</string>
<key>documentTypeString</key>
<string>&lt;nil&gt;</string>
<key>domainType</key>
<string>Xcode.IDEActivityLogDomainType.BuildLog</string>
<key>fileName</key>
<string>FE752EBA-0994-486D-9A0C-1DA5C49E3451.xcactivitylog</string>
<key>hasPrimaryLog</key>
<true/>
<key>primaryObservable</key>
<dict>
<key>highLevelStatus</key>
<string>S</string>
<key>totalNumberOfAnalyzerIssues</key>
<integer>0</integer>
<key>totalNumberOfErrors</key>
<integer>0</integer>
<key>totalNumberOfTestFailures</key>
<integer>0</integer>
<key>totalNumberOfWarnings</key>
<integer>0</integer>
</dict>
<key>schemeIdentifier-containerName</key>
<string>WorkbenchReplacement project</string>
<key>schemeIdentifier-schemeName</key>
<string>WorkbenchReplacement</string>
<key>schemeIdentifier-sharedScheme</key>
<integer>1</integer>
<key>signature</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>timeStartedRecording</key>
<real>813879926.65620303</real>
<key>timeStoppedRecording</key>
<real>813879942.82261503</real>
<key>title</key>
<string>Building project WorkbenchReplacement with scheme WorkbenchReplacement and configuration Debug</string>
<key>uniqueIdentifier</key>
<string>FE752EBA-0994-486D-9A0C-1DA5C49E3451</string>
</dict>
</dict>
</dict>
</plist>
@@ -1 +1 @@
1792186902.93557: Module build session file for module cache at Path(str: "/Volumes/Developer/Applications/WorkbenchReplacement/build/ModuleCache.noindex")
1792187127.0273461: Module build session file for module cache at Path(str: "/Volumes/Developer/Applications/WorkbenchReplacement/build/ModuleCache.noindex")
+1 -1
View File
@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>LastAccessedDate</key>
<date>2026-10-16T21:41:42Z</date>
<date>2026-10-16T21:45:26Z</date>
<key>WorkspacePath</key>
<string>/Volumes/Developer/Applications/WorkbenchReplacement/WorkbenchReplacement.xcodeproj</string>
</dict>
+9
View File
@@ -0,0 +1,9 @@
# Phase 22 — SQL diagnostics and plan observations
- Adds read-only interpretation of tabular MySQL EXPLAIN output: full scans, index scans, missing selected index, temporary tables, filesort and estimated row counts.
- Adds Copy Plan for tabular and JSON EXPLAIN output.
- Displays MySQL execution errors directly above the SQL editor, with selectable error text. No inaccurate error-line highlighting is attempted.
- Index observations are explicitly advisory and do not generate or execute DDL.
- Preserves Phase 21 and earlier project files.
Build and runtime validation on macOS / a MySQL server are still required.