Re: PQconnectdbParams vs PQconninfoParse

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: PQconnectdbParams vs PQconninfoParse
Дата
Msg-id 7939.1466690374@sss.pgh.pa.us
обсуждение исходный текст
Ответ на PQconnectdbParams vs PQconninfoParse  (Craig Ringer <craig@2ndquadrant.com>)
Ответы Re: PQconnectdbParams vs PQconninfoParse  (Craig Ringer <craig@2ndquadrant.com>)
Список pgsql-hackers
Craig Ringer <craig@2ndquadrant.com> writes:
> While writing some code that takes a connstring and adds some parameters, I
> noticed that PQconninfoParse doesn't play well with PQconnectdbParams.

> PQconnectdbParams takes a pair of equal-length arrays, one for keys and one
> for values, each terminated by null elements.  But PQconninfoParse returns
> a an array of PQconninfoOption .

> This means the client has to do a bunch of fiddling to turn a parsed
> conninfo into something that can be passed to PQconnectdbParams .  This
> seems bizarre. Am I missing something obvious?

Um, I don't see the connection.  Under what circumstances would you want
to pass the result of PQconninfoParse directly to PQconnectdbParams?
PQconninfoOption is intended to provide a lot of secondary information
about the available options, so it's more in the nature of an
informational record than something you would feed back into the library.

> libpq  internally uses connectOptions1 which calls parse_connection_string,
> the same function used by PQconninfoParse. But there's no connect variant
> exposed to users to use it.
> Anyone object to adding one?

This seems more like exposing library implementation details than adding
useful functionality.

In particular, I object to using PQconninfoOption as an input data
structure to the library, because then you'd have a bunch of definitional
questions about which fields of that struct the client app is expected to
make valid, plus the potential for well-hidden bugs if some part of the
library unintentionally relies on a field it shouldn't when looking at a
PQconninfoOption that came from outside the library rather than inside.
        regards, tom lane



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: Bug in to_timestamp().
Следующее
От: Rui Hai Jiang
Дата:
Сообщение: Re: how is the WAL receiver process stopped and restarted when the network connection is broken and then restored?