Skip to content

Add startup options parameter to ReplicationConfig - #10

Merged
vnvo merged 2 commits into
vnvo:mainfrom
mmmries:support-startup-options-parameter
Sep 21, 2026
Merged

vnvo merged 2 commits into
vnvo:mainfrom
mmmries:support-startup-options-parameter

Conversation

@mmmries

@mmmries mmmries commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

I wanted to set some connection level configs like timezone and intervalstyle, so I can reliably predict the exact byte-encoding I'll receive for values like timestamps and intervals.

ReplicationConfig::options: Option<String> (named to match tokio_postgres::Config::options) plus a with_options() builder, and thread it into the startup parameter list, only including the options key when it's Some. This lets callers pin session GUCs (DateStyle, IntervalStyle, etc.) on the replication connection the same way they already can on a normal libpq connection, so decoded WAL text agrees byte-for-byte with text rendered by a separately-configured connection pool.

I'm pretty new to rust development, so I'm more than happy to address any feedback you have and iterate on the solution if you're open to this PR.

The startup parameter list sent in worker::startup() was previously
fixed (user, database, replication, client_encoding, application_name)
with no way to set libpq's `options` parameter, and no way to issue a
SET after connecting either. PostgreSQL honors `options` on replication
connections the same as on ordinary ones (verified with
`PGOPTIONS='-c timezone=UTC -c intervalstyle=iso_8601' pg_recvlogical`,
which changed the walsender's rendered output as expected), so this
was a real, fixable gap rather than a protocol limitation.

Add `ReplicationConfig::options: Option<String>` (named to match
tokio_postgres::Config::options) plus a `with_options()` builder, and
thread it into the startup parameter list, only including the `options`
key when it's `Some`. This lets callers pin session GUCs (DateStyle,
IntervalStyle, etc.) on the replication connection the same way they
already can on a normal libpq connection, so decoded WAL text agrees
byte-for-byte with text rendered by a separately-configured connection
pool.

Docker isn't available in the environment this was developed in, so
this adds unit tests proving the startup parameter list includes
`options` when set and omits it when unset, rather than a full
testcontainers-based integration test.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@vnvo

vnvo commented Sep 21, 2026

Copy link
Copy Markdown
Owner

hey,
thanks, looks clean.
Just a small ask: could you also please update the README (feature list) and mention "connection-level configs" or something like that?

other than that, all good!

@mmmries

mmmries commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the quick feedback. I pushed an additional commit that updates the README with a 1-liner description.

@vnvo
vnvo merged commit 9eedf91 into vnvo:main Sep 21, 2026
4 checks passed
@vnvo

vnvo commented Sep 21, 2026

Copy link
Copy Markdown
Owner

merged --> 0.4.1

@mmmries
mmmries deleted the support-startup-options-parameter branch September 21, 2026 15:48
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.

2 participants