PQconnectdbParams vs PQconninfoParse

From: Craig Ringer <craig(at)2ndquadrant(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: PQconnectdbParams vs PQconninfoParse
Date: 2016-06-23 07:55:02
Message-ID: CAMsr+YEhyDqtXcjkiAF9h-EAu4yjtVf5prBYtA8Sz-i7T5GXCw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi all

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?

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? Like:

PQconnectStartInfo(PQconninfoOption options)
PQconnectdbInfo(PQconninfoOption options)

?

PQconnectStartParams(...) and PQconnectdbParams(...) would become thin
wrappers around it.

It's a pity that the name PQconnectdbParams is already taken, really.

--
Craig Ringer http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Terje Elde 2016-06-23 09:34:40 Feature suggestions: "dead letter"-savepoint.
Previous Message amul sul 2016-06-23 07:41:26 Re: Bug in to_timestamp().