fix: skip multi-statement SET validation in session mode#1157
Open
zefixlluja wants to merge 1 commit into
Open
fix: skip multi-statement SET validation in session mode#1157zefixlluja wants to merge 1 commit into
zefixlluja wants to merge 1 commit into
Conversation
In session mode, PgDog should forward multi-statement queries to the server verbatim without validating whether they mix SET with other commands. The server owns the session and can handle these naturally. Fixes a bug where queries like: SET DateStyle='ISO'; show transaction_isolation were rejected with 'multi-statement queries cannot mix SET with other commands' even when the pool was in session mode. Additional changes: - cargo fmt fix in context.rs (method-chain line break) - Unit tests: `test_mixed_set_passthrough_in_session_mode` and `test_mixed_set_rejected_in_transaction_mode` in test_set.rs - `Cluster::new_test_session_mode` and `QueryParserTest::new_session_mode` added as test helpers Co-authored-by: Ubuntu <ubuntu@ns5017323.ip-15-235-180.net> Closes pgdogdev#1087
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
In session mode, PgDog should forward multi-statement queries to the server verbatim without validating whether they mix SET with other commands. The server owns the session and can handle these naturally.
Previously,
try_multi_setunconditionally rejected any multi-statement batch mixing SET with non-SET statements (e.g. SHOW), returningError::MultiStatementMixedSet. This broke psqlODBC connections, which send exactly such a batch during connection startup:Changes
QueryParserContext::is_session_mode()— checks the cluster's pooler modetry_multi_setreturnsOk(None)early in session mode, letting the query fall through to the server unchangedcargo fmtfix incontext.rs(method-chain line break)test_mixed_set_passthrough_in_session_modeandtest_mixed_set_rejected_in_transaction_modeCluster::new_test_session_mode/QueryParserTest::new_session_modeadded as test helpersTest plan
cargo nextest run— new unit tests cover both session-mode passthrough and transaction-mode rejectionpooler_mode = sessionand verify the connection startup batch succeedsCloses #1087