Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
11def690
Commit
11def690
authored
Apr 28, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Missed some corner cases (PGSERVICE mostly)...
parent
092133be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
16 deletions
+30
-16
src/interfaces/libpq/fe-connect.c
src/interfaces/libpq/fe-connect.c
+30
-16
No files found.
src/interfaces/libpq/fe-connect.c
View file @
11def690
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.23
8 2003/04/28 04:29:12
tgl Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.23
9 2003/04/28 04:52:13
tgl Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -107,7 +107,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
...
@@ -107,7 +107,7 @@ static const PQconninfoOption PQconninfoOptions[] = {
{
"user"
,
"PGUSER"
,
NULL
,
NULL
,
{
"user"
,
"PGUSER"
,
NULL
,
NULL
,
"Database-User"
,
""
,
20
},
"Database-User"
,
""
,
20
},
{
"password"
,
"PGPASSWORD"
,
DefaultPassword
,
NULL
,
{
"password"
,
"PGPASSWORD"
,
NULL
,
NULL
,
"Database-Password"
,
"*"
,
20
},
"Database-Password"
,
"*"
,
20
},
{
"connect_timeout"
,
"PGCONNECT_TIMEOUT"
,
NULL
,
NULL
,
{
"connect_timeout"
,
"PGCONNECT_TIMEOUT"
,
NULL
,
NULL
,
...
@@ -1976,6 +1976,14 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
...
@@ -1976,6 +1976,14 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
int
linenr
=
0
,
int
linenr
=
0
,
i
;
i
;
/*
* We have to special-case the environment variable PGSERVICE here,
* since this is and should be called before inserting environment
* defaults for other connection options.
*/
if
(
service
==
NULL
)
service
=
getenv
(
"PGSERVICE"
);
if
(
service
!=
NULL
)
if
(
service
!=
NULL
)
{
{
FILE
*
f
;
FILE
*
f
;
...
@@ -2060,21 +2068,30 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
...
@@ -2060,21 +2068,30 @@ parseServiceInfo(PQconninfoOption *options, PQExpBuffer errorMessage)
* name of the service
* name of the service
*/
*/
for
(
i
=
0
;
options
[
i
].
keyword
;
i
++
)
for
(
i
=
0
;
options
[
i
].
keyword
;
i
++
)
{
if
(
strcmp
(
options
[
i
].
keyword
,
"dbname"
)
==
0
)
if
(
strcmp
(
options
[
i
].
keyword
,
"dbname"
)
==
0
)
{
if
(
options
[
i
].
val
==
NULL
)
if
(
options
[
i
].
val
==
NULL
)
options
[
i
].
val
=
strdup
(
service
);
options
[
i
].
val
=
strdup
(
service
);
break
;
}
}
val
=
line
+
strlen
(
line
)
+
1
;
val
=
line
+
strlen
(
line
)
+
1
;
/*
* Set the parameter --- but don't override any
* previous explicit setting.
*/
found_keyword
=
0
;
found_keyword
=
0
;
for
(
i
=
0
;
options
[
i
].
keyword
;
i
++
)
for
(
i
=
0
;
options
[
i
].
keyword
;
i
++
)
{
{
if
(
strcmp
(
options
[
i
].
keyword
,
key
)
==
0
)
if
(
strcmp
(
options
[
i
].
keyword
,
key
)
==
0
)
{
{
if
(
options
[
i
].
val
!=
NULL
)
if
(
options
[
i
].
val
==
NULL
)
free
(
options
[
i
].
val
);
options
[
i
].
val
=
strdup
(
val
);
options
[
i
].
val
=
strdup
(
val
);
found_keyword
=
1
;
found_keyword
=
1
;
break
;
}
}
}
}
...
@@ -2273,7 +2290,10 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
...
@@ -2273,7 +2290,10 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
/* Done with the modifiable input string */
/* Done with the modifiable input string */
free
(
buf
);
free
(
buf
);
/* Now check for service info */
/*
* If there's a service spec, use it to obtain any not-explicitly-given
* parameters.
*/
if
(
parseServiceInfo
(
options
,
errorMessage
))
if
(
parseServiceInfo
(
options
,
errorMessage
))
{
{
PQconninfoFree
(
options
);
PQconninfoFree
(
options
);
...
@@ -2282,12 +2302,12 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
...
@@ -2282,12 +2302,12 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
/*
/*
* Get the fallback resources for parameters not specified in the
* Get the fallback resources for parameters not specified in the
* conninfo string.
* conninfo string
nor the service
.
*/
*/
for
(
option
=
options
;
option
->
keyword
!=
NULL
;
option
++
)
for
(
option
=
options
;
option
->
keyword
!=
NULL
;
option
++
)
{
{
if
(
option
->
val
!=
NULL
)
if
(
option
->
val
!=
NULL
)
continue
;
/* Value was in conninfo */
continue
;
/* Value was in conninfo
or service
*/
/*
/*
* Try to get the environment variable fallback
* Try to get the environment variable fallback
...
@@ -2322,15 +2342,9 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
...
@@ -2322,15 +2342,9 @@ conninfo_parse(const char *conninfo, PQExpBuffer errorMessage)
}
}
/*
/*
* Special handling for dbname
* We used to special-case dbname too, but it's easier to let the
* backend handle the fallback for that.
*/
*/
if
(
strcmp
(
option
->
keyword
,
"dbname"
)
==
0
)
{
tmp
=
conninfo_getval
(
options
,
"user"
);
if
(
tmp
)
option
->
val
=
strdup
(
tmp
);
continue
;
}
}
}
return
options
;
return
options
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment