Repository navigation
pgconn: read the default service file from %APPDATA%\postgresql on Windows - #2697
Merged
Merged
Conversation
…ndows libpq looks for the per-user connection service file at %APPDATA%\postgresql\.pg_service.conf on Windows, next to pgpass.conf and the client certificates. pgx looked for it at %USERPROFILE%\.pg_service.conf instead, so a service set up for psql could not be found by pgx. The old location is still used when there is no service file at the libpq location, so existing setups keep working. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
|
Merged with a small tweak to the fallback logic. |
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.
On Windows, libpq looks for the per-user connection service file at
%APPDATA%\postgresql\.pg_service.conf, next topgpass.conf(see https://www.postgresql.org/docs/current/libpq-pgservice.html andpqGetHomeDirectoryin fe-connect.c). pgx looks for it at%USERPROFILE%\.pg_service.conf, so a service that works with psql can't be found by pgx:This makes the libpq location the default when
APPDATAis set, the same aspassfileand the SSL files already do. If there is no file there but%USERPROFILE%\.pg_service.confexists, pgx keeps using that one so existing setups don't break. Happy to drop that fallback if you'd rather match libpq exactly.The new tests in
pgconn/defaults_windows_test.goonly build on Windows. Two of them fail on master and all three pass with this change.This is an AI proposal: I used Claude Code (Claude Opus 5.5) to write this change. The prompt was a general "find, reproduce and fix a real bug in a Go database library" brief; it found this by comparing pgx's Windows defaults with libpq's.