pg_upgrade is a bit schizophrenic concerning the PGPORT environment
variable. On the one hand, there is this code in option.c that wants to
make use of it:
old_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;
new_cluster.port = getenv("PGPORT") ? atoi(getenv("PGPORT")) : DEF_PGPORT;
On the other hand, check.c will reject a set PGPORT because it's a libpq
environment variable. Should we make an exception for PGPORT, like we
did for PGCLIENTENCODING?