Skip to content

Support for the PG wire protocol#2702

Merged
mamcx merged 10 commits into
masterfrom
mamcx/pg-wire
Sep 10, 2025
Merged

Support for the PG wire protocol#2702
mamcx merged 10 commits into
masterfrom
mamcx/pg-wire

Conversation

@mamcx
Copy link
Copy Markdown
Contributor

@mamcx mamcx commented May 5, 2025

Description of Changes

Closes #2686.

Add support for listening using the PG wire protocol so pg clients could be used against the database.

API and ABI breaking changes

The output of duration is changed to rfc3339, instead of the way is made with sats because is what is done in pg, see note below.

Expected complexity level and risk

2

There is open questions that are in the ticket #2686. Also the crate used here require RustTls, so it could be good idea to decide if:

  • Rewrite a big chunk of code to use OpenSSL
  • Move to RustTls Remove openssl #1700
  • Pay for the extra compilation cost.

I open another port(5433) to listen for pg connections using ssl. Need to be decided if this is the way or instead try to multi-plex the current port for both protocols.

Testing

Only manual testing so far. Solving the above questions allow me to implement some unit tests. Also, not yet integrated into cloud for the same reasons.

  • Adding some test for the binary encoding of special and primitive types
  • Smoke test using psql that connect to the db instance and run some queries
  • Manually inspect using a UI database explorer how infer the types, some of this tools generate special widgets when displaying json, duration, etc

@mamcx mamcx self-assigned this May 5, 2025
@mamcx mamcx added enhancement New feature or request release-any To be landed in any release window backward-compatible labels May 5, 2025
@mamcx mamcx requested a review from joshua-spacetime May 15, 2025 20:17
@mamcx mamcx marked this pull request as ready for review May 15, 2025 20:17
@bfops
Copy link
Copy Markdown
Collaborator

bfops commented May 16, 2025

(It looks like this is currently failing tests)

@mamcx
Copy link
Copy Markdown
Contributor Author

mamcx commented May 16, 2025

(It looks like this is currently failing tests)

Yes, the unit test was a spurious network error, the others are problems with the smoke tests that need psql binary to be present. Working on it...

@mamcx mamcx force-pushed the mamcx/pg-wire branch 3 times, most recently from 982e1b1 to 25a2a5f Compare May 26, 2025 20:55
@mamcx mamcx requested review from Centril and removed request for joshua-spacetime May 26, 2025 20:55
@mamcx mamcx force-pushed the mamcx/pg-wire branch 4 times, most recently from 1881b10 to 08989c7 Compare July 17, 2025 15:54
Comment thread smoketests/tests/sql.py
@mamcx mamcx added api-break A PR that makes an API breaking change and removed backward-compatible labels Jul 17, 2025
@mamcx mamcx force-pushed the mamcx/pg-wire branch 2 times, most recently from 0d00322 to 80311ca Compare July 24, 2025 16:42
@sunng87
Copy link
Copy Markdown
Contributor

sunng87 commented Jul 25, 2025

@mamcx Hello Mario, this is author of pgwire. Let me know if you have any question with the integration. It's also helpful for me to know if you feel any component that can be or should be upstreamed.

@mamcx mamcx force-pushed the mamcx/pg-wire branch 2 times, most recently from 1569826 to d806fbb Compare August 7, 2025 17:01
Comment thread crates/cli/src/subcommands/sql.rs Outdated
Comment thread crates/client-api/src/auth.rs Outdated
Comment thread crates/pg/src/pg_server.rs Outdated
@mamcx mamcx force-pushed the mamcx/pg-wire branch 2 times, most recently from 3e7e6e4 to 141ea1a Compare September 2, 2025 22:38
Comment thread crates/standalone/src/subcommands/start.rs Outdated
@mamcx mamcx force-pushed the mamcx/pg-wire branch 4 times, most recently from abae080 to 59306e4 Compare September 5, 2025 20:17
Comment thread smoketests/tests/pg_wire.py Outdated
@mamcx mamcx force-pushed the mamcx/pg-wire branch 2 times, most recently from 2dfd505 to f020df2 Compare September 9, 2025 17:50
@mamcx mamcx enabled auto-merge September 10, 2025 19:42
Copy link
Copy Markdown
Collaborator

@bfops bfops left a comment

Choose a reason for hiding this comment

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

codeowned changes for me LGTM (crates/cli/src/subcommands/sql.rs)

Copy link
Copy Markdown
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

For the two files that I own this looks good to me. I take it we are supporting postgres formatted output and also SpacetimeDB for spacetime sql?

@mamcx mamcx added this pull request to the merge queue Sep 10, 2025
@mamcx
Copy link
Copy Markdown
Contributor Author

mamcx commented Sep 10, 2025

For the two files that I own this looks good to me. I take it we are supporting postgres formatted output and also SpacetimeDB for spacetime sql?

Correct.

Merged via the queue into master with commit 8adef2b Sep 10, 2025
24 of 25 checks passed
@bfops bfops deleted the mamcx/pg-wire branch May 6, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api-break A PR that makes an API breaking change enhancement New feature or request release-any To be landed in any release window

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for Clients Using the PostgreSQL Wire Protocol

6 participants