

Array entries appearing before an expanded dbname entry can be overridden by fields of the connection string, and in turn those fields are overridden by array entries appearing after dbname (but, again, only if those entries supply non-empty values).Īfter processing all the array entries and any expanded connection string, any connection parameters that remain unset are filled with default values. Thus, the programmer may determine whether array entries can override or be overridden by values taken from a connection string. This rule applies in particular when a key word found in a connection string conflicts with one appearing in the keywords array. If any key word is repeated, the last value (that is not NULL or empty) is used. In general the parameter arrays are processed from start to end. (More details on connection string formats appear in Section 33.1.1.) Only the first occurrence of dbname is treated in this way any subsequent dbname parameter is processed as a plain database name. The value is considered to be a connection string, rather than just a database name, if it contains an equal sign ( =) or it begins with a URI scheme designator. If so, it is “ expanded” into the individual connection parameters extracted from the string. When expand_dbname is non-zero, the value for the first dbname key word is checked to see if it is a connection string.

Also, if the values entry associated with a non- NULL keywords entry is NULL or an empty string, that entry is ignored and processing continues with the next pair of array entries. Processing will stop at the first NULL entry in the keywords array. The passed arrays can be empty to use all default parameters, or can contain one or more parameter settings.

The currently recognized parameter key words are listed in Section 33.1.2. Unlike PQsetdbLogin below, the parameter set can be extended without changing the function signature, so use of this function (or its nonblocking analogs PQconnectStartParams and PQconnectPoll) is preferred for new application programming. The second, values, gives the value for each key word. The first, keywords, is defined as an array of strings, each one being a key word. This function opens a new database connection using the parameters taken from two NULL-terminated arrays. PGconn *PQconnectdbParams(const char * const *keywords,

Makes a new connection to the database server.
