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
This PR adds a small, ppg-dev-focused WAL API to PGlite using built-in PostgreSQL logical decoding (
pgoutput) and SQL decoding functions.This is part of a temporary Prisma fork strategy to unblock ppg-dev while we prepare upstream PRs.
What we are building (ppg-dev scoped)
A minimal PGlite extension namespace with:
wal.ensure({ slot, publication, tables? })wal.poll({ slot, publication, maxChanges?, protoVersion? }) -> WalEvent[]And a pgoutput decoder that emits typed events:
begincommitrelationinsertupdatedeleteWhy this approach
For ppg-dev we want the simplest reliable path:
pgoutputformat.pg_create_logical_replication_slot,pg_logical_slot_get_binary_changes) instead of implementing replication protocol streaming.Changes in this PR
1) Startup Postgres config support in PGlite
postgresConfig?: Record<string, string | number | boolean>toPGliteOptions.-c key=valueentries frompostgresConfig.Files:
packages/pglite/src/interface.tspackages/pglite/src/pglite.ts2) WAL extension implementation
ensure: validateswal_level=logical, ensures publication and logical replication slot (pgoutputplugin).poll: fetches binary changes and decodes pgoutput into typed events.File:
packages/pglite/src/wal/index.ts3) Public exports
walextension andWalEventtype from package index.File:
packages/pglite/src/index.ts4) Test coverage
Added comprehensive coverage for:
postgresConfigstartup behavior (wal_level, replication limits)ensurebehavior and guardrailsFile:
packages/pglite/tests/wal.test.ts5) Test config aliasing for local
pg-protocolsource resolutionFile:
packages/pglite/vitest.config.tsValidation
packages/pglitetest suite successfully.ppg-dev usage pattern this enables
For each write query:
db.wal.poll(...)immediately.No
LISTEN/NOTIFYor idle polling loop is required for this scoped use case.Temporary fork publishing strategy
This branch is intended to be published as a temporary Prisma-owned package (or npm alias target) so
ppg-devcan depend on deterministic builds while upstream work proceeds.Upstream merge plan
electric-sql/postgres-pglite(paired repo PR).postgresConfigoption and WAL extension inelectric-sql/pglitewith this same minimal scope.Cross-repo dependency
This PR depends on the wasm runtime/linking fixes in:
prisma/postgres-pglitebranchwal(Companion PR link will be attached in comments.)
Companion PR: prisma/postgres-pglite#1