Skip to content

adapter: make DISCARD ALL reset session vars durably (SQL-529)#37790

Open
mtabebe wants to merge 1 commit into
MaterializeInc:mainfrom
mtabebe:sql-529-discard-reset
Open

adapter: make DISCARD ALL reset session vars durably (SQL-529)#37790
mtabebe wants to merge 1 commit into
MaterializeInc:mainfrom
mtabebe:sql-529-discard-reset

Conversation

@mtabebe

@mtabebe mtabebe commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Problem:
Over the extended query protocol, DISCARD ALL did not reset session variables to their defaults. It ended the transaction first and then staged the resets, but with no transaction left to commit the staged values were never promoted. Under the simple protocol the next implicit transaction happened to commit them, so the bug was invisible to the existing simple-protocol coverage.

Solution:
Add SessionVar::reset_durable, which clears the local, staged, and session values immediately, leaving default_value (the system/role/ startup default) intact so value_dyn falls through to it. Switch SessionVars::reset_all (the sole path used by DISCARD ALL) to use it, so the reset no longer depends on a later transaction commit and behaves identically across the simple and extended protocols.

Tests:

  • test/sqllogictest/discard.slt: extended-protocol reset-to-default case.
  • src/sql/src/session/vars.rs: unit tests for durable reset and for falling back to an installed (startup/role) default.
  • src/environmentd/tests/pgwire.rs: extended-protocol integration test driving DISCARD ALL via the extended protocol.

Fixes SQL-529

Problem:
Over the extended query protocol, `DISCARD ALL` did not reset session
variables to their defaults. It ended the transaction first and then
staged the resets, but with no transaction left to commit the staged
values were never promoted. Under the simple protocol the next implicit
transaction happened to commit them, so the bug was invisible to the
existing simple-protocol coverage.

Solution:
Add `SessionVar::reset_durable`, which clears the local, staged, and
session values immediately, leaving `default_value` (the system/role/
startup default) intact so `value_dyn` falls through to it. Switch
`SessionVars::reset_all` (the sole path used by `DISCARD ALL`) to use it,
so the reset no longer depends on a later transaction commit and behaves
identically across the simple and extended protocols.

Tests:
- test/sqllogictest/discard.slt: extended-protocol reset-to-default case.
- src/sql/src/session/vars.rs: unit tests for durable reset and for
  falling back to an installed (startup/role) default.
- src/environmentd/tests/pgwire.rs: extended-protocol integration test
  driving DISCARD ALL via the extended protocol.

Fixes SQL-529
@mtabebe
mtabebe marked this pull request as ready for review July 21, 2026 19:50
@mtabebe
mtabebe requested a review from a team as a code owner July 21, 2026 19:50
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.

1 participant