feat: add CockroachDB support#1262
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
LibPQDriverCoreand aLibPQBackedDriverprotocol. 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
CockroachPluginDriverusingSHOW CREATE TABLE/SHOW CREATE VIEW,SHOW INDEXES, andinformation_schema/pg_catalog. Server version comes fromversion().Plugin registration. CockroachDB registered as a
driverVariantofPostgreSQLDriverPlugin. A new generic "Connection Options" libpq field on the Advanced tab carries CockroachDB Cloud--cluster=routing.EXPLAIN. CockroachDB returns text plans, not JSON. New
CockroachDBPlanParserparses CockroachDB's tree output into the visual plan model.explainVariantsare 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 throughpluginTypeId, 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, terminalpsqlresolver, server dashboard, SQL function provider, TablePlus importer. Backup/restore and VACUUM are deliberately not offered, since CockroachDB supports neither.Tests
DatabaseTypeCockroachDBTests,ConnectionURLParserCockroachDBTests,CockroachDBPlanParserTestsswiftlint --strictcleanNeeds 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.