From 13ecb822e8da5668133b706474c25bc908ae370a Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Sat, 19 Apr 2014 08:41:51 -0400 Subject: [PATCH] libpq: have PQconnectdbParams() and PQpingParams accept "" as default Previously, these functions treated "" optin values as defaults in some ways, but not in others, like when comparing to .pgpass. Also, add documentation to clarify that now "" and NULL use defaults, like PQsetdbLogin() has always done. BACKWARD INCOMPATIBILITY Patch by Adrian Vondendriesch, docs by me Report by Jeff Janes --- doc/src/sgml/libpq.sgml | 12 ++++++------ src/interfaces/libpq/fe-connect.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml index be0d602508..1f0975ada6 100644 --- a/doc/src/sgml/libpq.sgml +++ b/doc/src/sgml/libpq.sgml @@ -131,15 +131,15 @@ PGconn *PQconnectdbParams(const char * const *keywords, The passed arrays can be empty to use all default parameters, or can contain one or more parameter settings. They should be matched in length. - Processing will stop with the last non-NULL element - of the keywords array. + Processing will stop at the first NULL element + in the keywords array. - If any parameter is unspecified, then the corresponding - environment variable (see ) - is checked. If the environment variable is not set either, - then the indicated built-in defaults are used. + If any parameter is NULL or an emptry string, the corresponding + environment variable (see ) is checked. + If the environment variable is not set either, then the indicated + built-in defaults are used. diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 3909367be6..0791774af7 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -4357,7 +4357,7 @@ conninfo_array_parse(const char *const * keywords, const char *const * values, const char *pname = keywords[i]; const char *pvalue = values[i]; - if (pvalue != NULL) + if (pvalue != NULL && pvalue[0] != '\0') { /* Search for the param record */ for (option = options; option->keyword != NULL; option++)