sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

Fix postgresql hostaddr semantics

Open mbj opened this issue 3 months ago • 0 comments

  • Before hostaddr was used to just be an alternative way to set host. But this is not how libpq actually behaves or intents hostaddr to be used.
  • Instead hostaddr is meant to contain a numeric IP address to connect to, bypassing DNS lookups. This can be useful if the DNS lookups are slow, or if the DNS lookup has to be bypassed as the port is proxied to localhost for ifrastructure reasons. The TLS verification is still always done against the host parameter. Basically it allows to do verify-full on proxied ports.

Libpq docs:

https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-PARAMKEYWORDS

Does your PR solve an issue?

Yes but issue was not reported yet, the original implementation of hostaddr parameters only misleading/bad semantics.

Is this a breaking change?

Can be argued both ways. Its definitively a bugfix, but could be that the bug is loadbearing. I'm fine either way, going to use a fork till release.

mbj avatar Nov 12 '25 14:11 mbj