Skip to content

fix: skip multi-statement SET validation in session mode#1157

Open
zefixlluja wants to merge 1 commit into
pgdogdev:mainfrom
zefixlluja:fix/1087-session-mode-multi-statement-set
Open

fix: skip multi-statement SET validation in session mode#1157
zefixlluja wants to merge 1 commit into
pgdogdev:mainfrom
zefixlluja:fix/1087-session-mode-multi-statement-set

Conversation

@zefixlluja

Copy link
Copy Markdown

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_set unconditionally rejected any multi-statement batch mixing SET with non-SET statements (e.g. SHOW), returning Error::MultiStatementMixedSet. This broke psqlODBC connections, which send exactly such a batch during connection startup:

SET DateStyle='ISO';SET extra_float_digits = 2;show transaction_isolation

Changes

  • QueryParserContext::is_session_mode() — checks the cluster's pooler mode
  • try_multi_set returns Ok(None) early in session mode, letting the query fall through to the server unchanged
  • 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
  • Cluster::new_test_session_mode / QueryParserTest::new_session_mode added as test helpers

Test plan

  • cargo nextest run — new unit tests cover both session-mode passthrough and transaction-mode rejection
  • Manual: connect via psqlODBC with pooler_mode = session and verify the connection startup batch succeeds

Closes #1087

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
@CLAassistant

CLAassistant commented Jul 7, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

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.

Session mode incorrectly rejects multi-statement queries mixing SET with other commands

2 participants