Skip to content

Run ALTER DATABASE SET and apply the stored settings at session start - #440

Merged
tamnd merged 1 commit into
mainfrom
alter-database-set
Oct 20, 2026
Merged

tamnd merged 1 commit into
mainfrom
alter-database-set

Conversation

@tamnd

@tamnd tamnd commented Oct 20, 2026

Copy link
Copy Markdown
Owner

Summary

pg_regress starts each run with ALTER DATABASE "regression" SET lc_messages TO 'C' and five more settings. rupg gave "ALTER is not supported yet", so pg_regress stopped before the first test and the pass count was 0 of 239. This PR runs ALTER DATABASE ... SET and applies the stored settings when a session of the database starts.

Changes

  • ALTER DATABASE name SET, SET ... FROM CURRENT, SET ... TO DEFAULT, RESET name and RESET ALL run as AlterDatabaseSet and AlterSetting do. The checks of validate_option_array_item come first: the name, the context and the value. A new value goes in place of the value of the same parameter, as GUCArrayAdd does.
  • The store keeps the settings of each database. DROP DATABASE removes them.
  • A new session applies the settings with the source database before the values of the startup packet, as process_settings does. RESET goes back to them, and pg_settings.source shows database.
  • pg_db_role_setting shows a row for each database with settings.
  • The statement runs in the simple and the extended protocol.

Known differences

  • The change does not wait for the end of the transaction. A rollback does not undo it.
  • ALTER ROLE ... SET is not supported yet, because rupg has one role.
  • A stored setting that is no longer valid gives no warning at the start of a session.

Tests

  • connection/alter_database_set.test is the output of PostgreSQL 19 for the same script: the errors, the placeholders and the rows of pg_db_role_setting.
  • database_settings starts a session of the database and checks the value, the source and RESET.

fmt, clippy, the workspace tests and the checks of xtask pass on server1.

@tamnd tamnd added kind/feature It does not do something that it must do. area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. labels Oct 20, 2026
@tamnd
tamnd merged commit 899bb83 into main Oct 20, 2026
5 checks passed
@tamnd
tamnd deleted the alter-database-set branch October 20, 2026 05:59
tamnd added a commit that referenced this pull request Oct 20, 2026
* Add the changelog entry for #440

* Run COPY FROM a file of the server
@tamnd tamnd mentioned this pull request Oct 20, 2026
1 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/session Sessions, settings, pooling and the server runtime. area/sql The grammar, the lexer, the analyzer and the rewriter. 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