Mismatch with libpq when hostaddr is specified in connection strings
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 14.3k
- Forks
- 1.1k
- Avg merge
- 6d 9h
- Merged PRs (30d)
- 11
Description
**Describe the bug**
Excited to see `pgx`'s efforts to improve compatibility with `libpq` connection strings!
But there are still some vital mismatches.
**Expected behavior**
See https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNECT-HOSTADDR
``` shell
$ psql "postgresql://someuser@hostname.not.used:54320/somedb?sslmode=require&host=hostname.for.sni&hostaddr=192.168.1.100"
Password for user someuser:
psql (18.4)
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_128_GCM_SHA256, compression: off, ALPN: postgresql)
Type "help" for help.
somedb=>
```
**Actual behavior**
When specified, `hostaddr` is not obeyed and treated as `unrecognized configuration parameter`.
**Version**
- Go: `go version go1.26.8 linux/amd64`
- PostgreSQL: `PostgreSQL 18.4 on x86_64-pc-linux-musl, compiled by gcc (Alpine 15.2.0) 15.2.0, 64-bit`
- pgx: `v5.11.0`
**Additional context**
I have digged a bit in `pgconn/config.go`. It seems to take some time to add new functionalities around `hostaddr`.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pgconn/config.go and compare its connection-string handling with PostgreSQL's libpq hostaddr documentation. Reproduce the supplied connection string, trace how hostaddr is classified, and inspect nearby coverage before making changes. Done means hostaddr is recognized and honored while host remains available for the SNI hostname, matching the documented libpq behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, postgresql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100