Skip to content

sql: ignore some session variables in RESET ALL #148770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

michae2
Copy link
Collaborator

@michae2 michae2 commented Jun 24, 2025

Looking at src/backend/utils/misc/guc_tables.c in PG source code, there are a few session variables flagged with GUC_NO_RESET_ALL that should not be affected by RESET ALL. This commit adds a NoResetAll flag to the following session variables that overlap with PG:

  • is_superuser
  • role
  • session_authorization
  • transaction_isolation
  • transaction_read_only

This commit also adds the flag to a couple CRDB-only session variables that seem similar:

  • transaction_priority
  • transaction_status

Most of these variables are read-only, and so were not affected by RESET ALL, but the new flag makes the intended behavior clear in case any of them do become writable in the future.

By fixing RESET ALL, this change also makes DISCARD ALL work correctly when default_transaction_use_follower_reads is enabled.

Fixes: #124150

Release note (bug fix): The RESET ALL statement is fixed to no longer affect the following session variables:

  • is_superuser
  • role
  • session_authorization
  • transaction_isolation
  • transaction_priority
  • transaction_status
  • transaction_read_only

This better matches PostgreSQL behavior for RESET ALL.

By fixing RESET ALL, the DISCARD ALL statement is also fixed to work correctly when default_transaction_use_follower_reads is enabled.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Looking at `src/backend/utils/misc/guc_tables.c` in PG source code,
there are a few session variables flagged with `GUC_NO_RESET_ALL` that
should not be affected by RESET ALL. This commit adds a `NoResetAll`
flag to the following session variables that overlap with PG:

- `is_superuser`
- `role`
- `session_authorization`
- `transaction_isolation`
- `transaction_read_only`

This commit also adds the flag to a couple CRDB-only session variables
that seem similar:

- `transaction_priority`
- `transaction_status`

Most of these variables are read-only, and so were not affected by RESET
ALL, but the new flag makes the intended behavior clear in case any of
them do become writable in the future.

By fixing RESET ALL, this change also makes DISCARD ALL work correctly
when `default_transaction_use_follower_reads` is enabled.

Fixes: cockroachdb#124150

Release note (bug fix): The RESET ALL statement is fixed to no longer
affect the following session variables:

- `is_superuser`
- `role`
- `session_authorization`
- `transaction_isolation`
- `transaction_priority`
- `transaction_status`
- `transaction_read_only`

This better matches PostgreSQL behavior for RESET ALL.

By fixing RESET ALL, the DISCARD ALL statement is also fixed to work
correctly when `default_transaction_use_follower_reads` is enabled.
@michae2 michae2 requested review from a team, mgartner and yuzefovich and removed request for a team June 24, 2025 23:08
@michae2 michae2 marked this pull request as ready for review June 24, 2025 23:09
Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch!

CREATE SEQUENCE discard_seq2 START WITH 10

statement ok
CREATE TEMP TABLE tempy (a int);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think the DISCARD ALL from line 199 is breaking this, since it resets experimental_enable_temp_tables

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Exactly right. Running into a different problem now, will update in a bit.

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice find! :lgtm:

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @michae2)

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.

Allow DISCARD ALL inside default_transaction_use_follower_reads
4 participants