Skip to content

feat: add CockroachDB support#1262

Merged
datlechin merged 1 commit into
mainfrom
feat/cockroachdb-support
May 14, 2026
Merged

feat: add CockroachDB support#1262
datlechin merged 1 commit into
mainfrom
feat/cockroachdb-support

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

Adds CockroachDB as a variant of the bundled PostgreSQL driver plugin, the same pattern used for Redshift. Connect over the PostgreSQL wire protocol, browse schema, run queries, and view EXPLAIN plans.

Implements the CockroachDB portion of #1226. Spanner is out of scope (no native wire-protocol path) and should be tracked separately.

What changed

Shared driver core. Extracted LibPQDriverCore and a LibPQBackedDriver protocol. The PostgreSQL and Redshift drivers were refactored onto it, removing ~240 lines of duplicated connection and execution boilerplate instead of triplicating it for CockroachDB.

CockroachDB driver. New CockroachPluginDriver using SHOW CREATE TABLE/SHOW CREATE VIEW, SHOW INDEXES, and information_schema/pg_catalog. Server version comes from version().

Plugin registration. CockroachDB registered as a driverVariant of PostgreSQLDriverPlugin. A new generic "Connection Options" libpq field on the Advanced tab carries CockroachDB Cloud --cluster= routing.

EXPLAIN. CockroachDB returns text plans, not JSON. New CockroachDBPlanParser parses CockroachDB's tree output into the visual plan model. explainVariants are now resolved per database type.

Per-type metadata fix. Several per-type properties (defaultPort, explainVariants, primaryUrlScheme, supportsSchemaEditing, and the schema-editing capability flags) were read through pluginTypeId, which resolves both CockroachDB and Redshift to "PostgreSQL". They now read the per-type snapshot. This also fixes latent Redshift bugs: wrong default port (5432 instead of 5439) and schema-editing UI that could not actually work.

Other integration. cockroachdb:// URL scheme, icon asset, terminal psql resolver, server dashboard, SQL function provider, TablePlus importer. Backup/restore and VACUUM are deliberately not offered, since CockroachDB supports neither.

Tests

  • New: DatabaseTypeCockroachDBTests, ConnectionURLParserCockroachDBTests, CockroachDBPlanParserTests
  • Full build clean, swiftlint --strict clean

Needs live validation

The schema-introspection SQL was written from CockroachDB's documented catalog behavior but not yet run against a live cluster. Browsing tables/columns/indexes/foreign keys, DDL, and EXPLAIN tree rendering should be verified against a real CockroachDB instance before release.

@datlechin datlechin merged commit ce57a7f into main May 14, 2026
2 checks passed
@datlechin datlechin deleted the feat/cockroachdb-support branch May 14, 2026 05:58
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.

1 participant