Re: WIP patch for Todo Item : Provide fallback_application_name in contrib/pgbench, oid2name, and dblink

From: Jeff Janes <jeff(dot)janes(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila(at)huawei(dot)com>, Shigeru HANADA <shigeru(dot)hanada(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: WIP patch for Todo Item : Provide fallback_application_name in contrib/pgbench, oid2name, and dblink
Date: 2014-02-10 17:14:39
Message-ID: CAMkU=1xeLo1E=-x2fkqU58OA-fAAU=yVLQ82T_oY_bBFminyzA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sun, Feb 9, 2014 at 4:56 PM, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:

> On Sun, Feb 9, 2014 at 6:33 PM, Jeff Janes <jeff(dot)janes(at)gmail(dot)com> wrote:
> >
> > Since this commit (17676c785a95b2598c573), pgbench no longer uses
> .pgpass to
> > obtain passwords, but instead prompts for a password
> >
> > This problem is in 9.3 and 9.4dev
> >
> > According to strace, it is reading the .pgpass file, it just seem like
> it is
> > not using it.
>
> Hmm. I tried pgbench with the following .pgpass file and it worked
> OK. Removing the file caused pgbench to prompt for a password.
>
> *:*:*:*:foo
>

OK, that works for me. I had it completely specified. Playing with
variations on this, I see that the key is pgport. Set to * it works, set
to 5432 it prompts for the password. (If I specify -p 5432 to pgbench,
that would work with the original file)

> 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.

*** a/contrib/pgbench/pgbench.c
--- b/contrib/pgbench/pgbench.c
*************** doConnect(void)
*** 528,533 ****
--- 528,535 ----

new_pass = false;

+ if (values[1][0] == 0) values[1]=NULL;
+
conn = PQconnectdbParams(keywords, values, true);

if (!conn)

Cheers,

Jeff

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2014-02-10 17:48:47 Re: Memory ordering issue in LWLockRelease, WakeupWaiters, WALInsertSlotRelease
Previous Message Pavel Stehule 2014-02-10 17:04:50 Re: proposal, patch: allow multiple plpgsql plugins