Skip to content

Commit 9270f1c

Browse files
committed
Only set the database name if we find a match in the services file.
1 parent 6f14e27 commit 9270f1c

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/interfaces/libpq/fe-connect.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.219 2003/01/07 04:25:29 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.220 2003/01/08 16:21:53 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -133,7 +133,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
133133

134134
{"hostaddr", "PGHOSTADDR", NULL, NULL,
135135
"Database-Host-IP-Address", "", 45},
136-
136+
137137
{"port", "PGPORT", DEF_PGPORT_STR, NULL,
138138
"Database-Port", "", 6},
139139

@@ -2338,12 +2338,6 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
23382338
return 1;
23392339
}
23402340

2341-
/* If not already set, set the database name to the name of the service */
2342-
for (i = 0; options[i].keyword; i++)
2343-
if (strcmp(options[i].keyword, "dbname") == 0)
2344-
if (options[i].val == NULL)
2345-
options[i].val = strdup(service);
2346-
23472341
while ((line = fgets(buf, MAXBUFSIZE - 1, f)) != NULL)
23482342
{
23492343
linenr++;
@@ -2408,6 +2402,16 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
24082402
fclose(f);
24092403
return 3;
24102404
}
2405+
2406+
/*
2407+
* If not already set, set the database name to the
2408+
* name of the service
2409+
*/
2410+
for (i = 0; options[i].keyword; i++)
2411+
if (strcmp(options[i].keyword, "dbname") == 0)
2412+
if (options[i].val == NULL)
2413+
options[i].val = strdup(service);
2414+
24112415
val = line + strlen(line) + 1;
24122416

24132417
found_keyword = 0;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy