Support the libpq options connection parameter - #11
Merged
Merged
Conversation
Pass a caller-supplied `options` value through to the server in the startup packet, as libpq does, so session defaults such as the schema search path can be set from a DSN or URI (`options='-c search_path=x'`). The value also defaults from PGOPTIONS, applies before the first query, and is re-sent on automatic reconnect because it lives in the startup packet rather than in a SET that would need replaying. An empty value is not sent. NUL bytes are rejected like the other startup strings. The driver's own client_encoding startup parameter is applied by the server after `options`, so a conflicting switch cannot break decoding; the reported encoding is still verified. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds libpq's
optionsconnection parameter (and thePGOPTIONSenvironment default). The value is passed through to the server in the startup packet exactly as libpq sends it, sooptions='-c search_path=myschema'sets the default schema for the session, as requested on Discourse (https://discourse.julialang.org/t/libpq-jl-in-2026-maintenance-status-and-postgresql-alternatives/139495/11).What changed
optionsis a keyword onPostgres.Connection,DBInterface.connect,ConnectionPool,ConnectionParams, and DSN/URI strings. It is no longer in the "accepted and ignored" set, sooptions=...is honored instead of rejected.optionsstartup parameter, afterapplication_name. An empty value is not sent, matching libpq. NUL bytes are rejected like the other startup strings.client_encoding=UTF8startup parameter is applied by the server afteroptions, and the reported encoding is still verified, so a conflicting-c client_encoding=...cannot break decoding (covered by a test).optionsis accepted since PgBouncer 1.20, andsearch_pathinside it is tracked by default only when the server reports it, i.e. PostgreSQL 18+; older servers needtrack_extra_parameters).Tests
PGOPTIONSdefault and override,ConnectionParamskeyword.SHOW search_pathafter connect and after a reconnect; DSN form with two switches; conflictingclient_encodingstill ends as UTF8; empty value connects; an unknown parameter surfaces asPostgres.Errorwith SQLSTATE42704.🤖 Generated with Claude Code