Jacob Champion <jacob.champion@enterprisedb.com> writes:
> A connection with only a hostaddr (no host) can't be cancelled via
> PQcreateCancel(), because we'll crash in emitHostIdentityInfo(). The
> problem is that the synthetic connhost entry we've created for
> cancellation has an incorrect type field, which causes the following
> code to make bad decisions if connhost[0].host is NULL:
I hadn't noticed (or maybe I forgot) this thread, so when the
same problem was reported at [1] I just went ahead and pushed the
submitted patch, which is only cosmetically different from your 0001.
Apologies for treading on your toes.
As for the question of how to test this sort of thing, I'm not
too excited about the narrow-gauge test case your 0002 proposes.
What I did for manual testing in [1] was to hack the postgres_fdw
tests to connect using hostaddr instead of the default. I think
formalizing that sort of approach would yield much better coverage.
I don't have any specific ideas about how to do it, though.
Maybe get our tests to respond to an environment variable that
allows overriding the default choices of connection properties?
regards, tom lane
[1] https://www.postgresql.org/message-id/flat/18974-575f02b2168b36b3%40postgresql.org