Skip to content

feat: implement get_table_ddl RPC method for dump support #118

Description

@aesslinger

Context

PR TabularisDB/tabularis#822 (PostgreSQL multi-database browsing) adds a new get_table_ddl method to the main repo's DriverTrait and dispatches it from RpcDriver as a "get_table_ddl" RPC call. The in-tree postgres/mysql/sqlite drivers have implementations that call their existing module-level get_table_ddl functions. The dump_database backend command now routes table-listing and DDL-fetch through this trait method instead of matching on the driver string directly, fixing the "Unsupported driver" failure for plugin-registered drivers.

The RpcDriver side in tabularis is wired — it calls self.process.call("get_table_ddl", json!({...})) — but this plugin doesn't yet have a handler for that method, so dump DDL for a plugin-installed Postgres connection will fail with a "method not implemented" error until this is added.

Request

Add a get_table_ddl RPC handler to this plugin, following the existing handler pattern (e.g. src/handlers/metadata.rs where get_tables, get_schemas, etc. live).

Expected RPC contract (inferred from how the main repo dispatches it, mirroring the existing PLUGIN_GUIDE.md patterns):

Request params: { "params": ConnectionParams, "table": "table_name", "schema": "schema_name | null" }
Result: "CREATE TABLE ..."  (a single string — the DDL for the existing table)

The simplest correct implementation for Postgres: query pg_catalog or use SHOW CREATE TABLE-equivalent constructions (e.g. reconstruct from pg_class/pg_attribute/pg_constraint) similar to how the deprecated in-tree src/drivers/postgres/mod.rs::get_table_ddl currently works in the main repo (before it gets removed). Alternatively, use pg_dump --schema-only --table=... subprocess if that's already plumbed in this plugin. The output just needs to be a valid CREATE TABLE statement that can be written into a .sql dump file.

Notes

  • This is only needed for dump-schema-structure support. The data export step in dump_database uses its own raw connection path and is unaffected.
  • The main repo's in-tree get_table_ddl in src/drivers/postgres/mod.rs is a good reference: it reconstructs the CREATE TABLE statement from information_schema.columns plus constraint queries. That implementation will eventually be removed when the in-tree postgres driver is fully deprecated.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions