Skip to content

feat: support pg protocol version negotiation for frontend clients using v3.2#926

Merged
levkk merged 1 commit intopgdogdev:mainfrom
sarajmunjal:issue-578
Apr 25, 2026
Merged

feat: support pg protocol version negotiation for frontend clients using v3.2#926
levkk merged 1 commit intopgdogdev:mainfrom
sarajmunjal:issue-578

Conversation

@sarajmunjal
Copy link
Copy Markdown
Contributor

@sarajmunjal sarajmunjal commented Apr 23, 2026

This PR adds frontend-side PostgreSQL protocol 3.2 support to PgDog - addressing #578.

PgDog now accepts 3.2 startup requests, negotiates newer 3.x minor versions down with NegotiateProtocolVersion, reports unsupported pq.* startup options in that response, and returns cancel keys / BackendKeyData in the right shape for the negotiated protocol. Backend connections to PostgreSQL are unchanged.

What changed

  • added protocol version parsing/negotiation and NegotiateProtocolVersion
  • updated startup parsing for 3.2, 3.3+ -> 3.2, and pq.* option reporting
  • updated BackendKeyData / CancelRequest handling for protocol-dependent secret lengths
  • generated client cancel keys based on the negotiated frontend protocol version
  • added unit and integration coverage for negotiation and extended cancel-key behavior
  • added an independent psql 18 smoke test pinned to exact 3.0 and 3.2

Compatibility

3.0 clients continue to work
3.2 clients are accepted directly
newer 3.x minor versions negotiate down to 3.2
non-3.x major versions remain unsupported

Verification

Ran locally:

cargo fmt --all
cargo test -p pgdog --lib --no-run
cargo test -p rust --test mod --no-run
cargo test -p rust --test mod integration::protocol_version:: -- --nocapture
bash integration/complex/protocol_version/run.sh

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 23, 2026

CLA assistant check
All committers have signed the CLA.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Comment thread .github/workflows/ci.yml
Comment thread integration/rust/tests/integration/protocol_version.rs
Copy link
Copy Markdown
Collaborator

@levkk levkk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing, thank you so much! Could you just push the rebase fix and this is good to go!

@sarajmunjal
Copy link
Copy Markdown
Contributor Author

@levkk rebased and pushed. I think rwx needs your approval to kick off?

@levkk levkk changed the title (feat): Support PostgreSQL protocol 3.2 negotiation for frontend clients feat: support pg protocol 3.2 negotiation for frontend clients Apr 25, 2026
@levkk levkk changed the title feat: support pg protocol 3.2 negotiation for frontend clients feat: support pg protocol version 3.2 negotiation for frontend clients Apr 25, 2026
@levkk levkk changed the title feat: support pg protocol version 3.2 negotiation for frontend clients feat: support pg protocol version negotiation for frontend clients using v3.2 Apr 25, 2026
@levkk
Copy link
Copy Markdown
Collaborator

levkk commented Apr 25, 2026

Will merge once tests pass (likely this weekend, worst case Monday).

@levkk levkk merged commit 2f70a7a into pgdogdev:main Apr 25, 2026
8 of 10 checks passed
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.

3 participants