pg.ddx.io psycopg/psycopg GitHub issues and pull requests
help / color / mirror / Atom feed[psycopg/psycopg] PR #1496: fix: read special connection params from the pg_service file
3+ messages / 2 participants
[nested] [flat]
* [psycopg/psycopg] PR #1496: fix: read special connection params from the pg_service file
@ 2026-11-12 00:56 "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: ritojoao (@ritojoao) @ 2026-11-12 00:56 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Close #698
Hello, and thank you for psycopg.
Some connection parameters are handled by psycopg itself: multiple hosts in `host`, the `host` to `hostaddr` async resolution, `connect_timeout` and `load_balance_hosts` (also `port` and `target_session_attrs`). These were looked up only in the connection string and in the `PG*` env vars, so values set in a pg_service file were ignored.
This change makes `_conninfo_utils.get_param()` look in the service file too, as the issue suggested. The precedence is the same as in libpq: connection string, then service file, then env var. The service name comes from `service=` or `PGSERVICE`. The files follow libpq: `PGSERVICEFILE` or else the user file (`~/.pg_service.conf`, or `%APPDATA%\postgresql\.pg_service.conf` on Windows), and then `$PGSYSCONFDIR/pg_service.conf` if the service was not found in the first file. Lines are trimmed as libpq does, but not the key and the value. The parsed file is cached by path and modification time.
Tests use temporary service files: multiple hosts, hostnames resolution, `load_balance_hosts`, `connect_timeout`, `PGSERVICE`, the system file fallback, whitespace parsing and the Windows and POSIX user file paths. I also added a line to `docs/news.rst`.
Limits:
- libpq uses a compile-time `SYSCONFDIR` when `PGSYSCONFDIR` is not set. That path cannot be known from Python, so it is not supported: the system file is read only if `PGSYSCONFDIR` is set.
- The parser is more lenient than libpq: lines without `=`, unknown keywords or a missing `PGSERVICEFILE` are ignored here, while libpq reports an error. Since the real connection still goes through libpq, those errors are still reported at connect time.
- I tested only on Windows, with the pure Python implementation (`PSYCOPG_IMPL=python`), and only the conninfo tests. The full test suite was not run and the C implementation was not tested.
Please let me know if you would prefer a different approach.
inline patch 1: docs/news.rst, psycopg/psycopg/_conninfo_utils.py, tests/test_conninfo.py and 2 more (+376/-2 lines) download inline-1.patch
diff --git a/docs/news.rst b/docs/news.rst
index 16ed74769..b3281cc2d 100644
--- a/docs/news.rst
+++ b/docs/news.rst
@@ -29,6 +29,10 @@ Psycopg 3.3.9
made pipeline mode, `~AsyncCursor.executemany()` and `~AsyncCopy.write()`
on async connections several times slower than on sync ones
(:ticket:`#1468`).
+- Use the values of ``host``, ``hostaddr``, ``port``, ``connect_timeout``,
+ ``load_balance_hosts``, ``target_session_attrs`` found in the service file,
+ not only the ones in the connection string and in the env vars
+ (:ticket:`#698`).
- Fix client-side quoting of negative zero floats and decimals, which could
produce a ``--`` SQL comment (:ticket:`#1480`).
- Raise `DataError` instead of `!ValueError` registering a composite whose
diff --git a/psycopg/psycopg/_conninfo_utils.py b/psycopg/psycopg/_conninfo_utils.py
index cc5774e23..b9188f353 100644
--- a/psycopg/psycopg/_conninfo_utils.py
+++ b/psycopg/psycopg/_conninfo_utils.py
@@ -7,6 +7,7 @@
from __future__ import annotations
import os
+import sys
from functools import lru_cache
from ipaddress import ip_address
from dataclasses import dataclass
@@ -68,12 +69,16 @@ def get_param(params: ConnMapping, name: str) -> str | None:
"""
Return a value from a connection string.
- The value may be also specified in a PG* env var.
+ The value may be also specified in a service file or in a PG* env var.
+ The precedence is the same as in libpq: connection string, service file,
+ env var.
"""
if name in params:
return str(params[name])
- # TODO: check if in service
+ if name != "service" and (service := _get_service(params)) is not None:
+ if (val := service.get(name)) is not None:
+ return val
if not (paramdef := get_param_def(name)):
return None
@@ -84,6 +89,83 @@ def get_param(params: ConnMapping, name: str) -> str | None:
return None
+def _get_service(params: ConnMapping) -> dict[str, str] | None:
+ """
+ Return the parameters of the service requested, if any.
+
+ Look for the service in the file specified by ``PGSERVICEFILE``, or in the
+ user and in the system service files, following libpq.
+ """
+ name = get_param(params, "service")
+ if not name:
+ return None
+
+ # Same order as libpq: PGSERVICEFILE or the user file, then the system
+ # file if the service wasn't found there.
+ if fn := os.environ.get("PGSERVICEFILE"):
+ pass
+ elif sys.platform == "win32":
+ appdata = os.environ.get("APPDATA")
+ fn = os.path.join(appdata, "postgresql", ".pg_service.conf") if appdata else ""
+ else:
+ home = os.path.expanduser("~")
+ fn = os.path.join(home, ".pg_service.conf") if home != "~" else ""
+
+ if fn and (rv := _read_service_file(fn, name)) is not None:
+ return rv
+
+ # libpq uses a compile-time SYSCONFDIR if PGSYSCONFDIR is not set. That
+ # value is not known from Python, so in that case the system file is not
+ # read.
+ if sysconf := os.environ.get("PGSYSCONFDIR"):
+ return _read_service_file(os.path.join(sysconf, "pg_service.conf"), name)
+
+ return None
+
+
+def _read_service_file(filename: str, service: str) -> dict[str, str] | None:
+ """
+ Return the parameters of a service in a file, None if not found.
+ """
+ try:
+ mtime = os.stat(filename).st_mtime_ns
+ except OSError:
+ return None
+ return _parse_service_file(filename, mtime).get(service)
+
+
+@lru_cache(maxsize=8)
+def _parse_service_file(filename: str, mtime: int) -> dict[str, dict[str, str]]:
+ # The mtime is only used to invalidate the cache if the file changes.
+ rv: dict[str, dict[str, str]] = {}
+ try:
+ with open(filename, encoding="utf-8", errors="replace") as f:
+ lines = f.read().splitlines()
+ except OSError:
+ return rv
+
+ # Whitespace as in libpq: trim the line, not the key or the value.
+ ws = " \t\n\r\f\v"
+ current: dict[str, str] | None = None
+ for line in lines:
+ line = line.strip(ws)
+ if not line or line.startswith("#"):
+ continue
+ if line.startswith("["):
+ # As in libpq, the first definition of a service wins.
+ name, sep, _ = line[1:].partition("]")
+ if not sep:
+ current = {} # malformed header: skip its content
+ else:
+ current = {} if name in rv else rv.setdefault(name, {})
+ continue
+ if current is not None and "=" in line:
+ key, val = line.split("=", 1)
+ current.setdefault(key, val)
+
+ return rv
+
+
@dataclass
class ParamDef:
"""
diff --git a/tests/test_conninfo.py b/tests/test_conninfo.py
index 62dc22e55..a5b5d739f 100644
--- a/tests/test_conninfo.py
+++ b/tests/test_conninfo.py
@@ -122,3 +122,15 @@ def test_timeout_bad_value(setpgenv, conninfo):
params = conninfo_to_dict(conninfo)
with pytest.raises(ProgrammingError, match="bad value for connect_timeout"):
timeout_from_conninfo(params)
+
+
+def test_timeout_from_service(setpgenv, tmp_path, monkeypatch):
+ setpgenv({"PGCONNECT_TIMEOUT": "7"})
+ fn = tmp_path / "pg_service.conf"
+ fn.write_text("[foo]\nconnect_timeout=11\n")
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+ assert timeout_from_conninfo(conninfo_to_dict("service=foo")) == 11
+ # The connection string has precedence on the service
+ assert timeout_from_conninfo(conninfo_to_dict("service=foo connect_timeout=5")) == 5
+ # The service has precedence on the env var
+ assert timeout_from_conninfo(conninfo_to_dict("service=bar")) == 7
diff --git a/tests/test_conninfo_attempts.py b/tests/test_conninfo_attempts.py
index 2c76c287f..fe9890bcb 100644
--- a/tests/test_conninfo_attempts.py
+++ b/tests/test_conninfo_attempts.py
@@ -1,6 +1,8 @@
# WARNING: this file is auto-generated by 'async_to_sync.py'
# from the original file 'test_conninfo_attempts_async.py'
# DO NOT CHANGE! Change the original file instead.
+import sys
+
import pytest
import psycopg
@@ -196,3 +198,135 @@ def test_conninfo_random_multi_ips(fake_resolve):
args["load_balance_hosts"] = "random"
hostaddrs = [str(att["hostaddr"]) for att in conninfo_attempts(args)]
assert hostaddrs != sorted(hostaddrs)
+
+
+@pytest.fixture
+def service_file(tmp_path, monkeypatch, setpgenv):
+ setpgenv({})
+
+ def write(content):
+ fn = tmp_path / "pg_service.conf"
+ fn.write_text(content)
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+
+ return write
+
+
+@pytest.mark.parametrize(
+ "conninfo, want",
+ [
+ (
+ "service=multi",
+ [
+ "service=multi host=1.1.1.1 port=5433 hostaddr=1.1.1.1",
+ "service=multi host=2.2.2.2 port=5433 hostaddr=2.2.2.2",
+ ],
+ ),
+ ("service=multi host=3.3.3.3", ["service=multi host=3.3.3.3 hostaddr=3.3.3.3"]),
+ (
+ "service=names",
+ [
+ "service=names host=foo.com hostaddr=1.1.1.1",
+ "service=names host=qux.com hostaddr=2.2.2.2",
+ ],
+ ),
+ ],
+)
+def test_conninfo_attempts_service(service_file, fake_resolve, conninfo, want):
+ service_file("""# a comment
+[multi]
+host=1.1.1.1,2.2.2.2
+port=5433
+
+[names]
+host=foo.com,qux.com
+""")
+ params = conninfo_to_dict(conninfo)
+ attempts = conninfo_attempts(params)
+ want = list(map(conninfo_to_dict, want))
+ assert want == attempts
+
+
+def test_conninfo_attempts_service_load_balance(
+ service_file, fake_resolve, monkeypatch
+):
+ service_file("[lb]\nhost=dup.com\nload_balance_hosts=random\n")
+ shuffled = []
+ mod = sys.modules[conninfo_attempts.__module__]
+ monkeypatch.setattr(mod, "shuffle", lambda x: shuffled.append(list(x)))
+ params = conninfo_to_dict("service=lb")
+ conninfo_attempts(params)
+ assert shuffled
+
+
+@pytest.fixture
+def service_env(tmp_path, monkeypatch, setpgenv):
+ setpgenv({})
+ for name in ("PGSERVICEFILE", "PGSYSCONFDIR", "APPDATA", "PGSERVICE"):
+ monkeypatch.delenv(name, raising=False)
+ return tmp_path
+
+
+def test_conninfo_attempts_pgservice_env(service_env, monkeypatch, fake_resolve):
+ fn = service_env / "svc.conf"
+ fn.write_text("[envsvc]\nhost=1.1.1.1,2.2.2.2\n")
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+ monkeypatch.setenv("PGSERVICE", "envsvc")
+ attempts = conninfo_attempts(conninfo_to_dict(""))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+def test_conninfo_attempts_service_system_fallback(
+ service_env, monkeypatch, fake_resolve
+):
+ # Service not in PGSERVICEFILE: libpq tries $PGSYSCONFDIR/pg_service.conf
+ user = service_env / "user.conf"
+ user.write_text("[other]\nhost=9.9.9.9\n")
+ sysdir = service_env / "sys"
+ sysdir.mkdir()
+ (sysdir / "pg_service.conf").write_text("[sysonly]\nhost=3.3.3.3,4.4.4.4\n")
+ monkeypatch.setenv("PGSERVICEFILE", str(user))
+ monkeypatch.setenv("PGSYSCONFDIR", str(sysdir))
+ attempts = conninfo_attempts(conninfo_to_dict("service=sysonly"))
+ assert [a["hostaddr"] for a in attempts] == ["3.3.3.3", "4.4.4.4"]
+
+ # A service found in the first file wins over the system file
+ (sysdir / "pg_service.conf").write_text("[other]\nhost=8.8.8.8,7.7.7.7\n")
+ attempts = conninfo_attempts(conninfo_to_dict("service=other"))
+ assert [a["hostaddr"] for a in attempts] == ["9.9.9.9"]
+
+
+def test_conninfo_attempts_service_whitespace(service_env, monkeypatch, fake_resolve):
+ # As in libpq: lines are trimmed, key and value are not.
+ fn = service_env / "svc.conf"
+ lines = [" [ws] ", " host=1.1.1.1,2.2.2.2 ", "[bad", "host=5.5.5.5"]
+ fn.write_text("\n".join(lines))
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+ attempts = conninfo_attempts(conninfo_to_dict("service=ws"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+def test_conninfo_attempts_service_windows_appdata(
+ service_env, monkeypatch, fake_resolve
+):
+ # On Windows libpq reads %APPDATA%\postgresql\.pg_service.conf
+ appdata = service_env / "appdata"
+ (appdata / "postgresql").mkdir(parents=True)
+ (appdata / "postgresql" / ".pg_service.conf").write_text(
+ "[win]\nhost=1.1.1.1,2.2.2.2\n"
+ )
+ monkeypatch.setenv("APPDATA", str(appdata))
+ mod = sys.modules["psycopg._conninfo_utils"]
+ monkeypatch.setattr(mod, "sys", type("S", (), {"platform": "win32"}))
+ attempts = conninfo_attempts(conninfo_to_dict("service=win"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+def test_conninfo_attempts_service_posix_home(service_env, monkeypatch, fake_resolve):
+ # On POSIX libpq reads ~/.pg_service.conf
+ (service_env / ".pg_service.conf").write_text("[home]\nhost=1.1.1.1,2.2.2.2\n")
+ mod = sys.modules["psycopg._conninfo_utils"]
+ monkeypatch.setattr(mod, "sys", type("S", (), {"platform": "linux"}))
+ monkeypatch.setattr(mod.os.path, "expanduser", lambda p: str(service_env))
+ attempts = conninfo_attempts(conninfo_to_dict("service=home"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
diff --git a/tests/test_conninfo_attempts_async.py b/tests/test_conninfo_attempts_async.py
index 8b694ddc8..921566a5e 100644
--- a/tests/test_conninfo_attempts_async.py
+++ b/tests/test_conninfo_attempts_async.py
@@ -1,3 +1,5 @@
+import sys
+
import pytest
import psycopg
@@ -203,3 +205,143 @@ async def test_conninfo_random_multi_ips(fake_resolve):
args["load_balance_hosts"] = "random"
hostaddrs = [str(att["hostaddr"]) for att in await conninfo_attempts_async(args)]
assert hostaddrs != sorted(hostaddrs)
+
+
+@pytest.fixture
+def service_file(tmp_path, monkeypatch, setpgenv):
+ setpgenv({})
+
+ def write(content):
+ fn = tmp_path / "pg_service.conf"
+ fn.write_text(content)
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+
+ return write
+
+
+@pytest.mark.parametrize(
+ "conninfo, want",
+ [
+ (
+ "service=multi",
+ [
+ "service=multi host=1.1.1.1 port=5433 hostaddr=1.1.1.1",
+ "service=multi host=2.2.2.2 port=5433 hostaddr=2.2.2.2",
+ ],
+ ),
+ (
+ "service=multi host=3.3.3.3",
+ ["service=multi host=3.3.3.3 hostaddr=3.3.3.3"],
+ ),
+ (
+ "service=names",
+ [
+ "service=names host=foo.com hostaddr=1.1.1.1",
+ "service=names host=qux.com hostaddr=2.2.2.2",
+ ],
+ ),
+ ],
+)
+async def test_conninfo_attempts_service(service_file, fake_resolve, conninfo, want):
+ service_file(
+ "# a comment\n"
+ "[multi]\n"
+ "host=1.1.1.1,2.2.2.2\n"
+ "port=5433\n"
+ "\n"
+ "[names]\n"
+ "host=foo.com,qux.com\n"
+ )
+ params = conninfo_to_dict(conninfo)
+ attempts = await conninfo_attempts_async(params)
+ want = list(map(conninfo_to_dict, want))
+ assert want == attempts
+
+
+async def test_conninfo_attempts_service_load_balance(
+ service_file, fake_resolve, monkeypatch
+):
+ service_file("[lb]\nhost=dup.com\nload_balance_hosts=random\n")
+ shuffled = []
+ mod = sys.modules[conninfo_attempts_async.__module__]
+ monkeypatch.setattr(mod, "shuffle", lambda x: shuffled.append(list(x)))
+ params = conninfo_to_dict("service=lb")
+ await conninfo_attempts_async(params)
+ assert shuffled
+
+
+@pytest.fixture
+def service_env(tmp_path, monkeypatch, setpgenv):
+ setpgenv({})
+ for name in ("PGSERVICEFILE", "PGSYSCONFDIR", "APPDATA", "PGSERVICE"):
+ monkeypatch.delenv(name, raising=False)
+ return tmp_path
+
+
+async def test_conninfo_attempts_pgservice_env(service_env, monkeypatch, fake_resolve):
+ fn = service_env / "svc.conf"
+ fn.write_text("[envsvc]\nhost=1.1.1.1,2.2.2.2\n")
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+ monkeypatch.setenv("PGSERVICE", "envsvc")
+ attempts = await conninfo_attempts_async(conninfo_to_dict(""))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+async def test_conninfo_attempts_service_system_fallback(
+ service_env, monkeypatch, fake_resolve
+):
+ # Service not in PGSERVICEFILE: libpq tries $PGSYSCONFDIR/pg_service.conf
+ user = service_env / "user.conf"
+ user.write_text("[other]\nhost=9.9.9.9\n")
+ sysdir = service_env / "sys"
+ sysdir.mkdir()
+ (sysdir / "pg_service.conf").write_text("[sysonly]\nhost=3.3.3.3,4.4.4.4\n")
+ monkeypatch.setenv("PGSERVICEFILE", str(user))
+ monkeypatch.setenv("PGSYSCONFDIR", str(sysdir))
+ attempts = await conninfo_attempts_async(conninfo_to_dict("service=sysonly"))
+ assert [a["hostaddr"] for a in attempts] == ["3.3.3.3", "4.4.4.4"]
+
+ # A service found in the first file wins over the system file
+ (sysdir / "pg_service.conf").write_text("[other]\nhost=8.8.8.8,7.7.7.7\n")
+ attempts = await conninfo_attempts_async(conninfo_to_dict("service=other"))
+ assert [a["hostaddr"] for a in attempts] == ["9.9.9.9"]
+
+
+async def test_conninfo_attempts_service_whitespace(
+ service_env, monkeypatch, fake_resolve
+):
+ # As in libpq: lines are trimmed, key and value are not.
+ fn = service_env / "svc.conf"
+ lines = [" [ws] ", " host=1.1.1.1,2.2.2.2 ", "[bad", "host=5.5.5.5"]
+ fn.write_text("\n".join(lines))
+ monkeypatch.setenv("PGSERVICEFILE", str(fn))
+ attempts = await conninfo_attempts_async(conninfo_to_dict("service=ws"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+async def test_conninfo_attempts_service_windows_appdata(
+ service_env, monkeypatch, fake_resolve
+):
+ # On Windows libpq reads %APPDATA%\postgresql\.pg_service.conf
+ appdata = service_env / "appdata"
+ (appdata / "postgresql").mkdir(parents=True)
+ (appdata / "postgresql" / ".pg_service.conf").write_text(
+ "[win]\nhost=1.1.1.1,2.2.2.2\n"
+ )
+ monkeypatch.setenv("APPDATA", str(appdata))
+ mod = sys.modules["psycopg._conninfo_utils"]
+ monkeypatch.setattr(mod, "sys", type("S", (), {"platform": "win32"}))
+ attempts = await conninfo_attempts_async(conninfo_to_dict("service=win"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
+
+
+async def test_conninfo_attempts_service_posix_home(
+ service_env, monkeypatch, fake_resolve
+):
+ # On POSIX libpq reads ~/.pg_service.conf
+ (service_env / ".pg_service.conf").write_text("[home]\nhost=1.1.1.1,2.2.2.2\n")
+ mod = sys.modules["psycopg._conninfo_utils"]
+ monkeypatch.setattr(mod, "sys", type("S", (), {"platform": "linux"}))
+ monkeypatch.setattr(mod.os.path, "expanduser", lambda p: str(service_env))
+ attempts = await conninfo_attempts_async(conninfo_to_dict("service=home"))
+ assert [a["hostaddr"] for a in attempts] == ["1.1.1.1", "2.2.2.2"]
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] PR #1496: fix: read special connection params from the pg_service file
@ 2026-11-12 11:57 ` "Binary-Refinery (@Binary-Refinery)" <noreply+Binary-Refinery@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: Binary-Refinery (@Binary-Refinery) @ 2026-11-12 11:57 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
I can run the conninfo cases on Linux with both implementations and check the explicit DSN, service-file and environment precedence. I can report the exact versions and any difference here.
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] PR #1496: fix: read special connection params from the pg_service file
@ 2026-11-12 17:43 ` "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: ritojoao (@ritojoao) @ 2026-11-12 17:43 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Thanks a lot, @Binary-Refinery! Running the conninfo cases on Linux with both implementations would be really helpful. Please share the results here when you have them.
In the meantime, I ran a Linux check myself, in case it helps.
**Setup:** Docker, `python:3.12`, PostgreSQL 17.11, libpq 17.11 (`pq.version()` 170011), branch at 10b8b28 (psycopg 3.3.9), installed from `./psycopg[test]` and `./psycopg_c`.
**Test suite.** I ran `tests/test_conninfo.py`, `tests/test_conninfo_attempts.py` and `tests/test_conninfo_attempts_async.py`:
| `PSYCOPG_IMPL` | Result |
|---|---|
| `python` | 116 passed |
| `c` | 116 passed |
**Precedence check.** For each case, a small script compares `get_param()` with what libpq resolves by itself: `PQconninfo()` on a raw `pq.PGconn.connect()`, with no psycopg logic involved. It checks `host`, `port`, `connect_timeout`, `load_balance_hosts` and `target_session_attrs`, then opens a real connection with `psycopg.connect()`. I got the same results with both implementations:
| Case | Result |
|---|---|
| `service=svc` only | OK |
| DSN `connect_timeout=3` beats the service file's `connect_timeout=7` | OK |
| Service file beats env (`PGHOST=nohost`, `PGCONNECT_TIMEOUT=9`) | OK |
| `PGSERVICE=svc` env, empty DSN | OK |
| `service=` in the DSN beats `PGSERVICE` | OK |
| Service with multiple hosts plus `load_balance_hosts=random` and `target_session_attrs=read-write` | OK |
| Fallback to `pg_service.conf` in the `PGSYSCONFDIR` directory | OK |
| Env only, no service | OK |
As a control, I swapped in `_conninfo_utils.py` from current master and ran the same script. It reports `host` and `connect_timeout` as unset for `service=svc`. In the "service beats env" case, connecting fails with `failed to resolve host None`, which is the behavior described in #698.
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-12 17:43 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 00:56 [psycopg/psycopg] PR #1496: fix: read special connection params from the pg_service file "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
2026-11-12 11:57 ` "Binary-Refinery (@Binary-Refinery)" <noreply+Binary-Refinery@github.com>
2026-11-12 17:43 ` "ritojoao (@ritojoao)" <noreply+ritojoao@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox