Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit95be343

Browse files
committed
Allow "dbname" from connection string to be overridden in PQconnectDBParams
If the "dbname" attribute in PQconnectDBParams contained a connection stringor URI (and expand_dbname = TRUE), the database name from the connectionstring could not be overridden by a subsequent "dbname" keyword in thearray. That was not intentional; all other options can be overridden.Furthermore, any subsequent "dbname" caused the connection string from thefirst dbname value to be processed again, overriding any values for the sameoptions that were given between the connection string and the second dbnameoption.In the passing, clarify in the docs that only the first dbname option in thearray is parsed as a connection string.Alex Shulgin. Backpatch to all supported versions.
1 parent5053ad2 commit95be343

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

‎src/interfaces/libpq/fe-connect.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4460,9 +4460,9 @@ conninfo_array_parse(const char **keywords, const char **values,
44604460
}
44614461

44624462
/*
4463-
* If we are on the dbname parameter, and we have a parsed
4464-
*conninfo string, copy those parameters across, overriding any
4465-
* existing previous settings
4463+
* If we are on thefirstdbname parameter, and we have a parsed
4464+
*connection string, copy those parameters across, overriding any
4465+
* existing previous settings.
44664466
*/
44674467
if (strcmp(pname,"dbname")==0&&str_options)
44684468
{
@@ -4494,6 +4494,12 @@ conninfo_array_parse(const char **keywords, const char **values,
44944494
}
44954495
}
44964496
}
4497+
/*
4498+
* Forget the parsed connection string, so that any subsequent
4499+
* dbname parameters will not be expanded.
4500+
*/
4501+
PQconninfoFree(str_options);
4502+
str_options=NULL;
44974503
}
44984504
else
44994505
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp