Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

tokio-postgres: prepare and execute unnamed statements in one roundtrip #6

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

tomhoule
Copy link

@tomhoule tomhoule commented Nov 7, 2023

@tomhoule and @pimeys paired this together today. This solves issues of random unnamed statement does not exist errors. They happen sometimes, but pretty often, especially if the roundtrip to the database is longer than localhost.

We remove pipelining completely from the query preparation, making this work to only be useful in a context of unnamed statements and text mode queries.

What used to be: PARSE, DESCRIBE, SYNC and load the response, then BIND and load the response is now: PARSE, DESCRIBE, FLUSH, BIND and then load the response. We skip one roundtrip, but by referring the Postgres manual, we know that an unnamed statement after a PARSE should not receive SYNC before loading the data, or the BIND might result in the error given above.

Eventually we remove a lot of stuff from this crate, maybe creating our own library while going. For now, it is recommended to not use anything else but the _txt methods in the client. Otherwise the sky can fall into your head.

@tomhoule tomhoule changed the title Add text protocol based query method (#14) e30b9c2df70a929dd2f3f1c63b86c484d26a9e98 Nov 7, 2023
@tomhoule tomhoule changed the title e30b9c2df70a929dd2f3f1c63b86c484d26a9e98 tokio-postgres: prepare and execute unnamed statements in one roundtrip Nov 7, 2023
@pimeys pimeys marked this pull request as ready for review November 7, 2023 13:56
@pimeys pimeys merged commit 72545c3 into grafbase Nov 7, 2023
@pimeys pimeys deleted the single-roundtrip-prepare-execute branch November 7, 2023 14:06
pimeys added a commit to grafbase/grafbase that referenced this pull request Nov 7, 2023
jakubadamw pushed a commit that referenced this pull request Mar 4, 2024
…ip (#6)

* tokio-postgres: prepare and execute unnamed statements in one roundtrip

* cleanup

---------

Co-authored-by: Julius de Bruijn <julius@nauk.io>
jakubadamw pushed a commit that referenced this pull request Mar 23, 2024
…ip (#6)

* tokio-postgres: prepare and execute unnamed statements in one roundtrip

* cleanup

---------

Co-authored-by: Julius de Bruijn <julius@nauk.io>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants