Repository navigation
Description
Summary
When the Compare feature is run against a server whose system tables are out of date (e.g. MariaDB upgraded but mariadb-upgrade never run), the entire comparison fails with a raw, unstructured error:
Comparison failed: Schema error: error returned from database: 1558 (HY000): Column count of mysql.proc is wrong. Expected 22, found 21. Created with MariaDB 110602, now running 120302. Please use mariadb-upgrade to fix this error
The error renders in a red banner with no explanation of what went wrong or what to do. The user has to know that MariaDB error 1558 means "run mariadb-upgrade on the server" to make sense of it.
Reproduction
- Connect to a MariaDB server whose data directory was upgraded from an older MariaDB version without running
mariadb-upgrade(e.g. data from MariaDB 11.6 with the server now running 12.3). - Open the Compare tab, pick the same server (Unraid in the screenshot) for both Source and Target with a non-system database (
aba_data). - Click Compare.
- Result: red banner with the cryptic string above. No comparison result, no actionable guidance.
Why this is a UX problem
- Error code 1558 is specific to the routines/procedure system table (
mysql.proc, surfaced viaINFORMATION_SCHEMA.ROUTINES). The user almost certainly does not need routine comparison — they want to diff tables, views, and triggers. - The error blocks the whole comparison even though every other schema component would have succeeded.
- The MariaDB-provided hint ("Please use mariadb-upgrade") is buried at the end of a long pasted string and offers no help with the SQLPilot flow.
- A grep of the repo shows no existing 1558 /
mariadb-upgradehandling anywhere — this is the first time a user has hit it via Compare.
Root cause
The Compare snapshot fetch treats routine introspection identically to tables/views/triggers and wraps everything in a single Promise.all:
src/components/compare/SchemaCompare.tsx:43-102 — fetchSnapshot:
const [tables, views, triggers, routines] = await Promise.all([
api.getTables(connectionId, database),
api.getViews(connectionId, database),
api.getTriggers(connectionId, database),
api.getRoutines(connectionId, database), // <-- this throws on 1558
]);api.getRoutines calls into the Rust SchemaInspector::get_routines (src-tauri/crates/mas-core/src/schema/inspector.rs:304-335), which queries INFORMATION_SCHEMA.ROUTINES (a view over mysql.proc on MariaDB). An un-upgraded server raises error 1558 there. The error bubbles up as a plain string from commands/mod.rs:298-315 (via .map_err(|e| e.to_string())), then is concatenated at:
src/components/compare/SchemaCompare.tsx:124:
setError(`Comparison failed: ${e}`);The error UI at SchemaCompare.tsx:161-166 is a plain string banner — no way to render a heading + body + actionable steps.
Per-routine DDL failures are already swallowed (SchemaCompare.tsx:76-82), and the backup generator already gates routines behind an includeRoutines option (src/lib/backup-generator.ts:242). The Compare feature is the odd one out.
Proposed fix
Three independent improvements, smallest to largest. Recommend all three.
1. Don't fail the whole comparison when routines can't be fetched
SchemaCompare.tsx:44-49 — split routines out of the main Promise.all and catch its failure per-side. Replace the all-or-nothing Promise.all with per-call try/catch that degrades to an empty routines array and surfaces a per-side warning.
Sketch:
async function fetchSnapshot(connectionId: string, database: string) {
const [tables, views, triggers] = await Promise.all([
api.getTables(connectionId, database),
api.getViews(connectionId, database),
api.getTriggers(connectionId, database),
]);
let routines: RoutineInfo[] = [];
let routinesError: string | null = null;
try {
routines = await api.getRoutines(connectionId, database);
} catch (err) {
routinesError = String(err);
}
return { tables, views, triggers, routines, routinesError };
}Then in handleCompare, accumulate routinesError from source and target into a non-fatal warning list passed to the results UI. The comparison itself proceeds with routines: [].
2. Detect the MariaDB-upgrade case (1558 / "mysql.proc" / "mariadb-upgrade") and show actionable guidance
Add a small helper that inspects the error string and returns a typed shape:
type CompareError =
| { kind: "routines-mariadb-upgrade"; side: "source" | "target"; raw: string }
| { kind: "generic"; message: string };
function classifyRoutinesError(err: string, side: "source" | "target"): CompareError {
if (/1558|mysql\.proc|mariadb-upgrade/i.test(err)) {
return { kind: "routines-mariadb-upgrade", side, raw: err };
}
return { kind: "generic", message: err };
}Upgrade the error state from string to a discriminated union (or a list of CompareErrors), and update the red banner at SchemaCompare.tsx:161-166 to render the structured shape:
- For
routines-mariadb-upgrade: show anAlertTriangle+ heading "MariaDB server upgrade needed for routine comparison" + body explaining the routines were skipped because the server'smysql.procschema is out of date, and listing the exact command:mariadb-upgrade -u root -p(run on the server). Include a "Dismiss" / "Retry" affordance. - For
generic: keep the current plain-string render (backward-compatible).
3. Add an opt-out toggle for routine comparison
SchemaCompare.tsx:132-203 — add a small checkbox near the setup row: "Include routines" (default on). When unchecked, skip the api.getRoutines call entirely. This lets users with broken server-side routine schemas still get a meaningful table/view/trigger comparison.
The backup flow already uses an includeRoutines flag (src/lib/backup-generator.ts:242); reuse the convention.
Optional follow-up (out of scope here)
- Enrich
CoreError::Schema(src-tauri/crates/mas-core/src/error.rs:11) to carry the underlying sqlx error code so the IPC payload can be structured rather than stringified. Bigger change, crosses the IPC contract — file as a separate issue. - Add a retry/refresh button on the Compare results panel that re-runs the snapshot with routines enabled once the user has run
mariadb-upgrade.
Acceptance criteria
- Compare against a MariaDB server with stale
mysql.proc:- Comparison completes (tables/views/triggers still diffed)
- Red banner is replaced by a yellow/info banner explaining routines were skipped and showing the
mariadb-upgradecommand - The user can dismiss the warning and the rest of the comparison result is fully usable
- Compare against a healthy server: no regression; routines included as today
- Unchecking "Include routines" before clicking Compare produces a full comparison with
routines: []and no warning - Generic (non-routine) errors still render the existing red string banner
Files
src/components/compare/SchemaCompare.tsx:43-102—fetchSnapshot; split routines into own try/catchsrc/components/compare/SchemaCompare.tsx:104-128—handleCompare; accumulate per-side routine errorssrc/components/compare/SchemaCompare.tsx:124— error string concat (replace with structured state)src/components/compare/SchemaCompare.tsx:161-166— error banner JSX (render structured shape)src/components/compare/SchemaCompare.tsx:132-203— setup row (addInclude routinescheckbox)src/lib/backup-generator.ts:242— reference pattern forincludeRoutinestogglesrc-tauri/crates/mas-core/src/schema/inspector.rs:304-335— Rustget_routines(reference, no change required)
Activity
fix: Compare - degrade-routines on MariaDB 1558 + dark-mode dropdowns (…
EVWorth commentedon Jul 20, 2026
Resolved by PR #231 (merged). Routines fetch now degrades gracefully per-side (graceful warning + opt-out checkbox); structured MariaDB-upgrade guidance replaces the brick-wall error. Frontend UX fix only — the IPC + Rust
get_routinespath is unchanged.Auto-close didn't fire on the merge (likely an issue reference parsing quirk with the
, #219comma form in the PR body).Out-of-scope followup noted in the PR body: enriching CoreError::Schema to carry structured sqlx error codes through IPC. Tracking separately if pursued.