pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #6657: Documentation bug for PQconnectdbParams
2+ messages / 2 participants
[nested] [flat]

* BUG #6657: Documentation bug for PQconnectdbParams
@ 2012-05-21 19:04  ediven@edsiohio.com
  0 siblings, 1 reply; 2+ messages in thread

From: ediven@edsiohio.com @ 2012-05-21 19:04 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      6657
Logged by:          Eric Diven
Email address:      ediven@edsiohio.com
PostgreSQL version: 9.0.2
Operating system:   Solaris
Description:        

First off, I should thank you all for the generally excellent documentation.
 The plpgsql documentation has been particularly helpful, in large part
thanks to the relevant and well-explained examples.

That said, I would humbly suggest that the documentation for the
PQconnectdbParams function omits certain details.  Notably, the function
will return NULL if you pass in a keywords array with an unrecognized
keyword.

I'll be the first to admit that passing in a keyword of "host_addr" instead
of "hostaddr" was kind of a dumb mistake on my part, but I'd argue that I'd
have figured it out a lot sooner if this were the documented behavior of
PQconnectdbParams for this case.

I realize I'm submitting this against an out of date version of postgresql,
and the the behavior might have changed since then, but since the
documentation covers all of 9.0.x, I would say that it still bears
updating.

Thanks,

Eric Diven

Example code follows:

#include <libpq-fe.h>

int main (int argc, char *argv[])
{
    PGconn *conn = NULL;
    char *keys[] = { "host_addr", "user", "password", NULL };
    char *values[] = { "192.168.0.42", "user", "password", NULL };

    conn = PQconnectdbParams (keys, values, 0);

    printf ("%p\n", conn);
    return 0;
}





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #6657: Documentation bug for PQconnectdbParams
@ 2012-05-21 23:51  Tom Lane <tgl@sss.pgh.pa.us>
  parent: ediven@edsiohio.com
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2012-05-21 23:51 UTC (permalink / raw)
  To: ediven@edsiohio.com; +Cc: pgsql-bugs

ediven@edsiohio.com writes:
> PostgreSQL version: 9.0.2
> ...
> That said, I would humbly suggest that the documentation for the
> PQconnectdbParams function omits certain details.  Notably, the function
> will return NULL if you pass in a keywords array with an unrecognized
> keyword.

This is a known bug that was fixed in 9.0.4.  When I try it now, I get a
PGconn object back, with status CONNECTION_BAD, and PQerrorMessage returns
	invalid connection option "host_addr"
which was the intended behavior all along, but there was a typo in 9.0;
see
http://git.postgresql.org/gitweb/?p=postgresql.git&a=commitdiff&h=672def62259354f28000e8cfb9...

In theory at least, you should only get a NULL back if there's
insufficient memory to create a PGconn object at all.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2012-05-21 23:51 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-05-21 19:04 BUG #6657: Documentation bug for PQconnectdbParams ediven@edsiohio.com
2012-05-21 23:51 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox