Skip to content

Commit

Permalink
Return the libpq default port when blank in conninfo
Browse files Browse the repository at this point in the history
PQport may return null or empty string when the same is set in
connection options. Internally, libpq falls back to its configured
default any time it reads these.
  • Loading branch information
cbandy committed Nov 12, 2022
1 parent b4a371d commit 68d40c5
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ext/pg_connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,10 @@ static VALUE
pgconn_port(VALUE self)
{
char* port = PQport(pg_get_pgconn(self));
return INT2NUM(atoi(port));
if (!port || port[0] == '\0')
return INT2NUM(DEF_PGPORT);
else
return INT2NUM(atoi(port));
}

/*
Expand Down

0 comments on commit 68d40c5

Please sign in to comment.