fix(postgres): propagate persistent to intermediary queries
#4062
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In some situations (e.g.: when using enums), sqlx will fire additional queries to fetch data from the database. Currently, these queries use
persistent=true, regardless of whether the parent query did. Unfortunately, this means that sqlx can't be used with connection poolers that don't support named prepared statements.In this patch, I try to propagate the
persistentattribute from the parent query to the other queries.Additionally, this requires a potential re-send of
Parse/Describe, as the additional queries will replace the existing one Postgres-side. For example, this is a sequence that could happen (after propagatingpersistent):This obviously won't work, as the second Parse message overwrote the unnamed prepared statement. Hence I added a re-preparation of the original query:
Let me know if I missed any place where this should be done, or if you disagree in the concept.
Is this a breaking change?
I don't believe so.