Skip to content

Commit a008c03

Browse files
committed
Fix pg_regress to print the correct postmaster address on Windows.
pg_regress reported "Unix socket" as the default location whenever HAVE_UNIX_SOCKETS is defined. However, that's not been accurate on Windows since 8f3ec75. Update this logic to match what libpq actually does now. This is just cosmetic, but still it's potentially misleading. Back-patch to v13 where 8f3ec75 came in. Discussion: https://postgr.es/m/3894060.1646415641@sss.pgh.pa.us
1 parent 5c9d17e commit a008c03

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1119,6 +1119,11 @@ connectOptions2(PGconn *conn)
11191119
{
11201120
if (ch->host)
11211121
free(ch->host);
1122+
1123+
/*
1124+
* This bit selects the default host location. If you change
1125+
* this, see also pg_regress.
1126+
*/
11221127
#ifdef HAVE_UNIX_SOCKETS
11231128
if (DEFAULT_PGSOCKET_DIR[0])
11241129
{

src/test/regress/pg_regress.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,16 @@ initialize_environment(void)
911911
*/
912912
pghost = getenv("PGHOST");
913913
pgport = getenv("PGPORT");
914-
#ifndef HAVE_UNIX_SOCKETS
915914
if (!pghost)
916-
pghost = "localhost";
915+
{
916+
/* Keep this bit in sync with libpq's default host location: */
917+
#ifdef HAVE_UNIX_SOCKETS
918+
if (DEFAULT_PGSOCKET_DIR[0])
919+
/* do nothing, we'll print "Unix socket" below */ ;
920+
else
917921
#endif
922+
pghost = "localhost"; /* DefaultHost in fe-connect.c */
923+
}
918924

919925
if (pghost && pgport)
920926
printf(_("(using postmaster on %s, port %s)\n"), pghost, pgport);

0 commit comments

Comments
 (0)