# pg_mooncake 0.3.4: pg_duckdb 1.2.1+ Support & Direct Upgrades

> pg_mooncake 0.3.4 accepts pg_duckdb 1.2.1 and later (reference build 1.2.2 on DuckDB v2.0.1), pins PGXS module versions in source archives, provides direct SQL upgrades from 0.3.0–0.3.3, and documents durable 0.3.0 WAL retirement.

---

LLMS index: [llms.txt](/llms.txt)

---

**v0\.3\.4 · 2026-11-24**
- [View release](https://github.com/pgsty/pg_mooncake/releases/tag/v0.3.4)
- [Source · tar\.gz](https://github.com/pgsty/pg_mooncake/archive/refs/tags/v0.3.4.tar.gz)
- [Source · zip](https://github.com/pgsty/pg_mooncake/archive/refs/tags/v0.3.4.zip)
- [pgsty\/pg\_mooncake](https://github.com/pgsty/pg_mooncake)

**`pg_mooncake 0.3.4`** removes the rigid exact-version lock on `pg_duckdb`, accepting **`pg_duckdb 1.2.1` and later** on installation and upgrade while advancing the reference build to **`pg_duckdb 1.2.2`** (embedding **DuckDB `v2.0.1`**). It continues to bundle [**`Moonlink v0.3.0-pgsty.2`**](/release/moonlink-0.3.0-pgsty.2/) and [**`duckdb_mooncake v0.0.5`**](/release/duckdb-mooncake-0.0.5/), provides direct SQL upgrades from all prior PGSTY `0.3.x` releases (`0.3.0` through `0.3.3`), and has been validated end-to-end across **PostgreSQL 15 through 19**.

## Component Matrix {#components}

| Component | Version / Tag | Revision | Notes |
| :--- | :--- | :--- | :--- |
| **`pg_mooncake`** | `v0.3.4` | `479f8ec8c2` | PostgreSQL 15–19 (`pgrx 0.20.0`, Rust `1.99.1`) |
| **`pg_duckdb`** | `>= 1.2.1` (ref `1.2.2`) | `4e921ffbe4` | Lower-bound SemVer check; reference `1.2.2` and `1.2.1` both embed DuckDB `v2.0.1` |
| **`moonlink`** | [`v0.3.0-pgsty.2`](/release/moonlink-0.3.0-pgsty.2/) | `bae6634bf6` | Durable Iceberg snapshot acknowledgements; Iceberg `0.11.0`, Arrow/Parquet `58.4.2`, SQLx `0.9.1` |
| **`duckdb_mooncake`** | [`v0.0.5`](/release/duckdb-mooncake-0.0.5/) | `89413ba02d` | DuckDB `v2.0.1` (`8d78114e90`); per-scan connections & pinned durability RPC |
{.wide .expand}

## Summary of Changes {#changes}

| Area | Change |
| :--- | :--- |
| `pg_duckdb >= 1.2.1` lower bound | Replaces the exact `pg_duckdb = 1.2.1` guard with semantic-version lower-bound enforcement (handling numeric `major.minor.patch` and prerelease precedence) across installation and upgrade SQL scripts. Both tested `pg_duckdb` `1.2.1` and `1.2.2` embed DuckDB `v2.0.1` and share bundled scanner `v0.0.5`. Operators choosing a newer `pg_duckdb` with a different DuckDB engine must verify its PostgreSQL interfaces and supply scanner `v0.0.5` built for that engine and platform. |
| Pinned PGXS module version | Adds `scripts/pg_duckdb.mk` and overrides `CPPFLAGS` with `-DPG_DUCKDB_VERSION` from `versions.json`, rebuilding `src/pgduckdb.o` whenever pins change so source builds emit the pinned `pg_duckdb` module version consistently in both Git checkouts and unpacked source archives. |
| Direct SQL upgrades (`0.3.0`–`0.3.3`) | Ships direct SQL upgrade scripts `0.3.0--0.3.4`, `0.3.1--0.3.4`, `0.3.2--0.3.4`, and `0.3.3--0.3.4`. Existing `0.3.2` and `0.3.3` mirror registrations and generations are preserved while enforcing `pg_duckdb >= 1.2.1` and loaded scanner `v0.0.5`. |
| Durable `0.3.0` WAL retirement guide | Documents how to emit a transactional logical WAL marker and take a verified Iceberg snapshot (`flush_lsn`) before retiring the legacy `0.3.0` worker's private `_wal` directory offline. |
{.wide .expand}

## Upgrading to `0.3.4` {#upgrade}

### From `0.3.1`, `0.3.2`, or `0.3.3` {#upgrade-031-033}

1. Install the `pg_mooncake 0.3.4` libraries, compatible `pg_duckdb` (`>= 1.2.1`, reference `1.2.2`), and scanner `v0.0.5` into your local `mooncake.extension_repository`, then restart PostgreSQL.
2. If upgrading from `0.3.1` or `0.3.2`, refresh the cached DuckDB scanner before updating the extension, then open a fresh session so the backend loads `v0.0.5`:
   ```sql
   SELECT duckdb.raw_query(
       format('FORCE INSTALL mooncake FROM %L', current_setting('mooncake.extension_repository'))
   );
   ```
3. In each database with `pg_mooncake` installed, update `pg_duckdb` (if its installed library changed) and update `pg_mooncake`:
   ```sql
   ALTER EXTENSION pg_duckdb UPDATE TO '1.2.2';
   ALTER EXTENSION pg_mooncake UPDATE TO '0.3.4';
   ```
4. If upgrading from `0.3.1` or `0.3.2`, run a fresh `CALL mooncake.create_snapshot(...)` on every mirror before using it as a backup or migration boundary.

### From WAL-Based PGSTY `0.3.0` {#upgrade-030}

PGSTY `0.3.0` used `Moonlink v0.0.1` (`b298ef74`), which could acknowledge source changes into its private `_wal` before Iceberg persistence. Perform these steps on **every database with mirrors** before switching binaries:

1. Stop writers to every source table (including remote sources) and take a recoverable backup of both PostgreSQL and the complete Moonlink directory.
2. On the **old `0.3.0` binaries**, wait until each mirror matches its quiescent source (comparing all columns in both directions with `EXCEPT ALL`) and record each mirror's `commit_lsn` from `mooncake.list_tables()`. For a source on the same PostgreSQL cluster, run both statements in the same autocommit session so `create_snapshot` receives a commit LSN after the last source write:
   ```sql
   SELECT pg_catalog.pg_logical_emit_message(true, 'pg_mooncake_upgrade', 'snapshot');
   CALL mooncake.create_snapshot('schema.mirror');
   ```
   Recheck `mooncake.list_tables()` and proceed **only** once `flush_lsn` covers the recorded source change (including a delete that emptied a mirror).
3. Stop PostgreSQL cleanly, move the old `_wal` directory outside the active Moonlink data directory and keep it with your backup (the new worker refuses to start if a nonempty `_wal` remains).
4. Install the matched `pg_mooncake 0.3.4`, `pg_duckdb`, and scanner `v0.0.5`, start PostgreSQL, and run `ALTER EXTENSION pg_duckdb UPDATE TO '1.2.2';` (if upgraded) followed by `ALTER EXTENSION pg_mooncake UPDATE TO '0.3.4';` in a fresh session.
5. Re-verify source/mirror parity, commit one identifiable test change, verify it in the mirror, and take a fresh snapshot before resuming writers. See the [full upgrade guide](https://github.com/pgsty/pg_mooncake/blob/v0.3.4/README.md#upgrading-a-pgsty-030-installation) for remote-source details.

## Source Release Assets & Checksums {#assets}

The attached `pg_mooncake-0.3.4-source.tar.gz` bundles all pinned Git submodules. Verify with `sha256sum -c SHA256SUMS` (`shasum -a 256 -c SHA256SUMS` on macOS). See [changes since `v0.3.3`](https://github.com/pgsty/pg_mooncake/compare/v0.3.3...v0.3.4) for the exact commit diff.

```checksums
0b92e9d2ceb297be4862fc54444b40f585f0a0aceaa96b018de18b89c528e7bb  pg_mooncake-0.3.4-source.tar.gz
470812b9d2f53397dc964a3134a3bf08af0475682af54b7ad2c7fe8fbf7aa036  SHA256SUMS
```

## Validation {#validation}

| Platform & Engine | Coverage |
| :--- | :--- |
| **Linux ARM64 · PostgreSQL 15, 16, 17, 18, 19** | Tested with both `pg_duckdb 1.2.1` and `pg_duckdb 1.2.2`. With `1.2.2`, every PostgreSQL major (`15`–`19`) passed all **10** `pg_regress` SQL suites and full integration checks across real server restarts. |
| **macOS ARM64 · PostgreSQL 19** | Passed full SQL regression suites and post-restart integration checks. |
| **Upgrade matrix** | Direct SQL upgrades from all four previous PGSTY versions (`0.3.0`, `0.3.1`, `0.3.2`, `0.3.3`) exercised end-to-end with existing mirror data. |
{.wide .expand}

---

Backlinks:

- [duckdb_mooncake 0.0.4: Isolated Scan Connections & DuckDB 2.0.1](/release/duckdb-mooncake-0.0.4/)
- [duckdb_mooncake 0.0.5: Durability-Pinned RPC & DuckDB 2.0 CI](/release/duckdb-mooncake-0.0.5/)
- [moonlink 0.3.0: WAL-Free Iceberg Recovery & Hardened CDC](/release/moonlink-0.3.0/)
- [moonlink 0.3.0-pgsty.1: Mirror Generations, Iceberg 0.11 & Security Audit](/release/moonlink-0.3.0-pgsty.1/)
- [moonlink 0.3.0-pgsty.2: Durable Iceberg Snapshot Acknowledgements](/release/moonlink-0.3.0-pgsty.2/)
- [pg_mooncake 0.3.2: PostgreSQL 15–19, Mirror Generations & Iceberg 0.11](/release/pg-mooncake-0.3.2/)
- [pg_mooncake 0.3.3: Durable Snapshot Acknowledgements](/release/pg-mooncake-0.3.3/)
