Re: Improvement to psql's connection defaults

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomas Zubiri <me(at)tomaszubiri(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Improvement to psql's connection defaults
Date: 2019-12-16 14:17:06
Message-ID: 16720.1576505826@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tomas Zubiri <me(at)tomaszubiri(dot)com> writes:
> The problem was that running the command psql without arguments
> returned the following
> error message:
> psql: could not connect to server: No such file or directory
> Is the server running locally and accepting
> connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?

The reason this failed, most likely, is using a semi-broken installation
in which libpq has a different idea than the server of where the
unix socket should be. The right fix is one or the other of

(a) don't mix-and-match Postgres packages from different vendors,

(b) adjust the server's unix_socket_directories parameter so that
it creates a socket where your installed libpq expects to find it.

I realize that this isn't great from a newbie-experience standpoint,
but unfortunately we don't have a lot of control over varying
packager decisions about the socket location --- both the "/tmp"
and the "/var/run/postgresql" camps have valid reasons for their
choices.

I do not think your proposal would improve matters; it'd just introduce
yet another variable, ie which transport method did libpq choose.
As Christoph noted, that affects authentication behaviors, and there
are a bunch of other user-visible impacts too (SSL, timeouts, ...).

If we were going to do something of this sort, what I'd be inclined
to think about is having an option to probe both of the common socket
directory choices, rather than getting into TCP-land. But that still
might be a net negative from the standpoint of confusion vs. number of
cases it fixes.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2019-12-16 14:47:11 Re: Improvement to psql's connection defaults
Previous Message Laurenz Albe 2019-12-16 14:09:51 Re: Request to be allotted a project or a feature in pipeline