From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Tatsuo Ishii <ishii(at)postgresql(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Question regarding psql or libpq |
Date: | 2010-12-16 15:22:02 |
Message-ID: | 21251.1292512922@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tatsuo Ishii <ishii(at)postgresql(dot)org> writes:
> It seems psql(or libpq) connects to PostgreSQL twice when md5 auth is
> required. Here is a strace log on my Linux machine. Is there any
> reason for this? IMO frontend/backend protocol allows to send salt
> after receiving AuthenticationMD5Password using the same socket. So
> there's no reason to close the socket and make it again. It seems to
> be just waste of resource.
The sequence of events is
1. psql attempts connection
2. libpq receives md5 challenge, realizes it doesn't have password, fails
3. psql collects password from user, tries again
4. libpq successfully makes connection
AFAICS the only alternatives to two connections are
(A) Have psql demand a password from the user before it knows whether
one is needed. Nonstarter for obvious reasons.
(B) Complicate the libpq API to the point where a partially open
connection could be held onto while we ask for a password. Very
messy, and could fail anyway if user takes more than auth_timeout
to enter the password, or enters the wrong password first time.
Two connections are not really a problem IMO, so I would not be in favor
of kluging the API to the extent required by solution (B).
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2010-12-16 15:23:43 | Re: directory archive format for pg_dump |
Previous Message | Bruce Momjian | 2010-12-16 15:20:44 | Re: Crash on attempt to connect to nonstarted server |