tomoakin / RPostgreSQL

Automatically exported from code.google.com/p/rpostgresql
64 stars 20 forks source link

please support PQconnectdb() interface #123

Closed iynehz closed 2 years ago

iynehz commented 2 years ago

Now RPostgreSQL uses PQsetdbLogin() https://github.com/tomoakin/RPostgreSQL/blob/85879044a3d4f4b8e9e2da46a971143a8f86c109/RPostgreSQL/src/RS-PostgreSQL.c#L305

But according to pq doc, PQconnectdb() is preferred.

https://www.postgresql.org/docs/8.3/libpq-connect.html

       PGconn *PQconnectdb(const char *conninfo);

This function opens a new database connection using the parameters taken from the string conninfo. Unlike PQsetdbLogin below, the parameter set can be extended without changing the function signature, so use of this function (or its nonblocking analogues PQconnectStart and PQconnectPoll) is preferred for new application programming.

At our workspace we would like to use the krbsrvname connection parameter, and we would avoid the env var approach as it's somewhat dirty. But RPostgreSQL does not directly support the parameter. And studying the matter further makes me think it better to support the PQconnectdb() interface which is a better solution for longer term.

tomoakin commented 2 years ago

In the explanation of PQsetdbLogin, they write:

If the dbName contains an = sign, it is taken as a conninfo string in exactly the same way as if it had been passed to 
PQconnectdb, and the remaining parameters are then applied as above.

implying that what you want should be doable by passing everything through the string passed via dbname = at dbConnect().

iynehz commented 2 years ago

Thanks! I didn't saw that part of PQsetdbLogin doc. This ticket can be closed.