On Tue, Apr 1, 2014 at 10:32:01AM -0400, Tom Lane wrote: > Adrian Vondendriesch <adrian.vondendrie...@credativ.de> writes: > > I patched the function conninfo_array_parse() which is used by > > PQconnectStartParams to behave like PQsetdbLogin. The patch also > > contains a document patch which clarify "unspecified" parameters. > > I see no documentation update here. I'm also fairly concerned about the > implication that no connection parameter, now or in future, can ever have > an empty string as the correct value.
I thought about this. We have never needed PQsetdbLogin() to handle zero-length strings specially in all the years we used it, so I am not sure why we would ever need PQconnectdbParams() to handle it. I am thinking we should make PQconnectdbParams() handle zero-length strings the same as NULL, and document it. Attached is a slightly-modified version of Adrian Vondendriesch's patch. -- Bruce Momjian <br...@momjian.us> http://momjian.us EnterpriseDB http://enterprisedb.com + Everyone has their own god. +
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml new file mode 100644 index be0d602..1f0975a *** a/doc/src/sgml/libpq.sgml --- b/doc/src/sgml/libpq.sgml *************** PGconn *PQconnectdbParams(const char * c *** 131,145 **** <para> 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-<symbol>NULL</symbol> element ! of the <literal>keywords</literal> array. </para> <para> ! If any parameter is unspecified, then the corresponding ! environment variable (see <xref linkend="libpq-envars">) ! is checked. If the environment variable is not set either, ! then the indicated built-in defaults are used. </para> <para> --- 131,145 ---- <para> 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 at the first <symbol>NULL</symbol> element ! in the <literal>keywords</literal> array. </para> <para> ! If any parameter is NULL or an emptry string, the corresponding ! environment variable (see <xref linkend="libpq-envars">) is checked. ! If the environment variable is not set either, then the indicated ! built-in defaults are used. </para> <para> diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c new file mode 100644 index 10cc0e6..45df6ce *** a/src/interfaces/libpq/fe-connect.c --- b/src/interfaces/libpq/fe-connect.c *************** conninfo_array_parse(const char *const * *** 4352,4358 **** const char *pname = keywords[i]; const char *pvalue = values[i]; ! if (pvalue != NULL) { /* Search for the param record */ for (option = options; option->keyword != NULL; option++) --- 4352,4358 ---- const char *pname = keywords[i]; const char *pvalue = values[i]; ! if (pvalue != NULL && pvalue[0] != '\0') { /* Search for the param record */ for (option = options; option->keyword != NULL; option++)
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers