Skip to content

Add support for CopyBoth mode #2923

Open
@grim7reaper

Description

@grim7reaper

Is your feature request related to a problem? Please describe.
I'm currently working on a daemon that will consume PostgreSQL replication logs (through logical replication).

Replication in Postgres, be it physical or logical, goes through the CopyBoth "protocol".
Today sqlx only supports CopyIn and CopyOut.

Moreover, to enable replication you need to setup a connection to the server and request the walsender mode, which isn't possible with the current options exposed by PgConnectOptions.

Describe the solution you'd like
Two things:

  • expose the replication mode parameter in PgConnectOptions, to be able to setup a "replication connection".
  • basic support for CopyBoth mode: something that let me receive and send raw bytes is enough (basically what already exists for CopyIn and CopyOut), there is no need for parsing/decoding the Streaming Replication Protocol (I can handle this on my side).

Describe alternatives you've considered

AFAIK, there is no support for replication Postgres libraries in Rust.

There is an open PR from 2015 for tokio-postgres (and a fork by Materialize).
But since the rest of our codebase is using sqlx1 I would rather stay on this stack 😁

Additional context

I already have a working implementation, gonna open a PR and waiting for your feedback/review to hopefully integrate this 🙂


Footnotes

  1. Compile-time checked query is a killer feature, you did a great job!! Can't live without it now! Need the same for ScyllaDB 😅

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions