jackc / jackc/pgx

Mismatch with libpq when hostaddr is specified in connection strings

Open
#2,655 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.