Hi,
Am Wed, 12 Feb 2014 13:47:41 -0500
schrieb Robert Haas <robertmhaas@gmail.com>:
> On Mon, Feb 10, 2014 at 12:14 PM, Jeff Janes <jeff.janes@gmail.com>
> wrote:
> >> Presumably whatever behavior difference you are seeing is somehow
> >> related to the use of PQconnectdbParams() rather than
> >> PQsetdbLogin(), but the fine manual does not appear to document a
> >> different between those functions as regards password-prompting
> >> behavior or .pgpass usage.
> >
> > It looks like PQsetdbLogin() has either NULL or empty string passed
> > to it match 5432 in pgpass, while PQconnectdbParams() only has NULL
> > match 5432 and empty string does not. pgbench uses empty string if
> > no -p is specified.
> >
> > This make pgbench behave the way I think is correct, but it hardly
> > seems like the right way to fix it.
> >
> > [ kludge ]i
>
> Well, it seems to me that the threshold issue here is whether or not
> we should try to change the behavior of libpq. If not, then your
> kludge might be the best option. But if so then it isn't necessary.
> However, I don't feel confident to pass judgement on the what the
> libpq semantics should be.
>
I noticed that pgbnech doesn't use all variables from my PGSERVICE
definition. Then I came around and find this Thread.
> export PGSERVICE=test_db_head
> cat ~/.pg_service.conf
> [test_db_head]
> host=/tmp
> user=avo
> port=5496
> dbname=pgbench
> /usr/local/postgresql/head/bin/pgbench -s 1 -i
> Connection to database "" failed:
> could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
As you noticed before pgbench initialises some of its connection
parameters with empty string, this overwrites variables defined
in .pg_service.conf.
I patched the function conninfo_array_parse() which is used by
PQconnectStartParams to behave like PQsetdbLogin. The patch also
contains a document patch which clarify "unspecified" parameters.
Now, PQconnectStartParams will handle empty strings in exactly the same
way as it handles NULL and pgbench run as expected:
> usr/local/postgresql/head/bin/pgbench -s 1 -i
> NOTICE: table "pgbench_history" does not exist, skipping
> NOTICE: table "pgbench_tellers" does not exist, skipping
> NOTICE: table "pgbench_accounts" does not exist, skipping
> NOTICE: table "pgbench_branches" does not exist, skipping
> creating tables...
> 100000 of 100000 tuples (100%) done (elapsed 0.21 s, remaining 0.00
> s). vacuum...
> set primary keys...
> done.
Kind Regards
- Adrian