Skip to content

Add set_config and the transaction mode checks after a query - #163

Merged
tamnd merged 1 commit into
mainfrom
m2-setconfig
Oct 8, 2026
Merged

tamnd merged 1 commit into
mainfrom
m2-setconfig

Conversation

@tamnd

@tamnd tamnd commented Oct 8, 2026

Copy link
Copy Markdown
Owner

This PR adds set_config, which is SET as a function, and the rule that a transaction cannot change its isolation level after its first query. With it, the session item of M2 is complete.

What changes

  • rupg-func has the kernel of set_config_by_name. A null name gives 22004, a null value resets the parameter, and a null is_local is false, as in guc_funcs.c.
  • The Session trait of rupg-func has set_setting. The reader of rupg-session changes the settings of the connection through a RefCell, with the same checks as SET, the check of role and session_authorization included. The change counts for the rest of the query. The zone of TimeZone is made again when the setting changes, so Session::zone now gives an Rc.
  • An error or a rollback undoes the change through the stack of the transaction that SET already uses, and a local change ends with its transaction. A changed reported parameter, such as TimeZone, DateStyle or search_path, is reported before ReadyForQuery.
  • Settings knows when the transaction took its first snapshot, as FirstSnapshotSet does. A query takes it when it is analyzed in a Query or a Parse message, and in Bind and Execute. After it, check_transaction_isolation, check_transaction_deferrable and check_transaction_read_only give 25001. SHOW and the other utility statements take no snapshot.

Tests

  • The new test set_config sends 44 queries to a connection and checks the rows, the errors and the ParameterStatus messages. Each expected value is the output of the PostgreSQL 19 oracle for the same statement.
  • The new test transaction_modes_after_a_query checks SET TRANSACTION after a query in a block, in an implicit block and after Parse, against the oracle.
  • cargo fmt, cargo clippy --workspace --all-targets -D warnings, cargo test --workspace and the cargo xtask checks pass on server1.

@tamnd tamnd added this to the M2: Connect and introspect milestone Oct 8, 2026
@tamnd tamnd added kind/bug It does the wrong thing. kind/feature It does not do something that it must do. area/session Sessions, settings, pooling and the server runtime. area/functions Built-in functions and operators. labels Oct 8, 2026
@tamnd tamnd self-assigned this Oct 8, 2026
@tamnd
tamnd merged commit ee9c1eb into main Oct 8, 2026
5 checks passed
@tamnd
tamnd deleted the m2-setconfig branch October 8, 2026 05:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/functions Built-in functions and operators. area/session Sessions, settings, pooling and the server runtime. kind/bug It does the wrong thing. kind/feature It does not do something that it must do.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant