Hello!

Shouldn't srvhost be freed in freePGconn?

+ /*
+ * If srvhost is set, validate mutual exclusivity with host/hostaddr and
+ * then resolve _postgresql._tcp.<srvhost> SRV records, populating
+ * conn->pghost and conn->pgport from the sorted results.  This must
+ * happen before the host-array allocation below.
+ */
+ if (conn->srvhost != NULL && conn->srvhost[0] != '\0')

Shouldn't this also cover port? The current behavior with it seems inconsistent.

> The resolved host list is sorted per RFC 2782 and injected into the
> existing multi-host machinery before connhost[] is built, so
> target_session_attrs, load_balance_hosts, and failover work on the
> expanded list without any changes to PQconnectPoll.

Doesn't RFC 2782 specifies a weighted random selection? The current
code seems to be deterministically sorted by weight.
RFC also says that weight=0 should be specially handled, it provides a
detailed algorithm about the random selection method.


Reply via email to