Handle pg_catalog.set_config session state#1069
Conversation
|
Stacked follow-up for incremental review: https://github.com/erayack/pgdog/pull/1 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a2b7f5e15d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| Some(SetParam { | ||
| name: Self::string_const(&func.args[0])?, | ||
| value: ParameterValue::String(Self::string_const(&func.args[1])?), | ||
| local: Self::bool_const(&func.args[2])?, |
There was a problem hiding this comment.
Preserve multi-entry search_path values
When set_config is used for a multi-entry search_path, e.g. SELECT set_config('search_path', 'public, pg_catalog', false), this stores the whole second argument as a single ParameterValue::String. On the next backend checkout PgDog replays tracked params via SET "search_path" TO {value}, so that value becomes SET "search_path" TO "public, pg_catalog", which PostgreSQL interprets as one quoted schema name rather than the two schemas that were actually set. This breaks session-state replay for clients that use set_config with normal comma-separated search paths.
Useful? React with 👍 / 👎.
|
Thank you for your submission. I apologize for not assigning myself to the issue sooner. Unfortunately this pull request overlaps with work the pgdog staff already had in progress. Duplicate of #1072 |
|
No worries, thanks for letting me know. If any part of this implementation or the tests are useful, you’re welcome to cherry-pick or copy them.
|
Summary
Fixes PgDog session-state tracking for
pg_catalog.set_config(...), which is used by tools likepg_dumpto mutate settings such assearch_path.Before this change, PgDog forwarded:
to PostgreSQL normally, but did not update the client-side Parameters state. If the client later received a different pooled backend connection, PgDog would not replay the
updated setting, so queries could run with a stale search_path.
This PR:
Semantics
set_config(name, value, false) is tracked like session SET:
set_config(name, value, true) is tracked like SET LOCAL:
Unsupported forms remain normal queries, for example:
Tests
Added coverage for:
Fixes #1055