Skip to content

Commit 5939274

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 97031f4 commit 5939274

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
@@ -1100,6 +1100,11 @@ connectOptions2(PGconn *conn)
11001100
{
11011101
if (ch->host)
11021102
free(ch->host);
1103+
1104+
/*
1105+
* This bit selects the default host location. If you change
1106+
* this, see also pg_regress.
1107+
*/
11031108
#ifdef HAVE_UNIX_SOCKETS
11041109
if (DEFAULT_PGSOCKET_DIR[0])
11051110
{

src/test/regress/pg_regress.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,10 +895,16 @@ initialize_environment(void)
895895
*/
896896
pghost = getenv("PGHOST");
897897
pgport = getenv("PGPORT");
898-
#ifndef HAVE_UNIX_SOCKETS
899898
if (!pghost)
900-
pghost = "localhost";
899+
{
900+
/* Keep this bit in sync with libpq's default host location: */
901+
#ifdef HAVE_UNIX_SOCKETS
902+
if (DEFAULT_PGSOCKET_DIR[0])
903+
/* do nothing, we'll print "Unix socket" below */ ;
904+
else
901905
#endif
906+
pghost = "localhost"; /* DefaultHost in fe-connect.c */
907+
}
902908

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

0 commit comments

Comments
 (0)