Skip to content

feat: Add pg_partman extension support - #1090

Open
gauthamchandra wants to merge 1 commit into
electric-sql:mainfrom
gauthamchandra:gauthamchandra/pg_partman
Open

feat: Add pg_partman extension support#1090
gauthamchandra wants to merge 1 commit into
electric-sql:mainfrom
gauthamchandra:gauthamchandra/pg_partman

Conversation

@gauthamchandra

Copy link
Copy Markdown

Summary

Ports pg_partman 5.5.0 to PGlite as @electric-sql/pglite-pg_partman, following the pgmq package as a template.

pg_partman's core is pure PL/pgSQL, so the WASM bundle is the upstream extension built SQL-only (NO_BGW=1, an officially supported upstream build mode): its background worker is just a scheduler that calls run_maintenance_proc(), and background workers cannot exist in single-process WASM. The embedding application decides when to call run_maintenance() instead.

Slight deviation from other packages:

Unlike other packages, I noticed that pg_partman tests their functionality utilizing pgTAP and since pglite supports
pgTAP, I decided to create 2 sets of tests:

  1. Basic smoke tests that runs common pg_partman queries.
  2. A set of pgTAP powered tests that takes the basic functionality promised in pglite for pg_partman and runs the
    original tests that the pg_partman team themselves use. In the event there's something wrong with the backend
    portion of this extension, the pgTAP tests hopefully should catch it. There's even a small script to help pull fresh
    versions of these files directly from upstream so its not a manual process.

Ports pg_partman 5.5.0 to PGlite as @electric-sql/pglite-pg_partman,
following the pgmq package template.

pg_partman's core is pure PL/pgSQL, so the WASM bundle is the upstream
extension built SQL-only (NO_BGW=1, an officially supported upstream
build mode): its background worker is just a scheduler that calls
run_maintenance_proc(), and background workers cannot exist in
single-process WASM. The embedding application decides when to call
run_maintenance() instead.

Tests come in two layers: a vitest smoke suite in the house style, and
a small TAP harness that runs eight of pg_partman's own pgTAP test
files verbatim (639 assertions) as the behavioural spec. The vendored
files are byte-identical to upstream v5.5.0; the only runtime
transformation is stripping psql backslash meta-commands, which have
no meaning outside psql. The remaining upstream suites need the
background worker, tablespaces, sub-partitioning lock headroom or
multi-session commits, and are intentionally out of scope for now.

**NOTE**: requires the pg_partman dist rule in postgres-pglite; the
submodule pointer will be bumped here once that backend PR merges.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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