From: | Peter Eisentraut <peter_e(at)gmx(dot)net> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | PostgreSQL Development <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: libpq PGHOST |
Date: | 2000-10-02 19:07:58 |
Message-ID: | Pine.LNX.4.21.0010022026510.1205-100000@peter.localdomain |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane writes:
> > The current behaviour of libpq is to use Unix sockets whenever the host
> > parameter (PGHOST or setdbLogin argument) is NULL/unset.
> > Could we extend that to also use Unix sockets if the parameter is set but
> > empty?
> Seems reasonable, since the current behavior in that case is useless:
> $ PGHOST='' psql
> psql: connectDBStart() -- unknown hostname:
> $
> Backwards compatibility with that doesn't seem necessary ...
After further investigation, there seems to be a larger unset/empty mess.
When using PQconnectdb(), a NULL parameter (keyword was not given at all)
means to use the environment variable, an explicit empty argument is used
as is. When using PGsetdbLogin(), however both NULL and empty arguments
cause the environment variable to be used. (An environment variable is
always used as is.)
Consequently, if PGHOST is set in the environment and your application is
using PGsetdbLogin(), then it's just impossible to get a Unix socket
connection.
(Note that this is independent of the proposed change, because PGHOST may
be set to some "real" string that you might wish to override.)
If we were to sort this out, then I think we'd need to change
PQsetdbLogin() to take empty arguments uniformly "as is", and make the
change to make Unix sockets also with an empty host parameter, as
proposed. Then you could use psql -h '' to request a Unix socket
explicitly.
Somewhat related:
peter=# create function "" () returns int as 'select 42' language 'sql';
CREATE
peter=# select ""();
----
42
(1 row)
That was probably not the plan.
--
Peter Eisentraut peter_e(at)gmx(dot)net http://yi.org/peter-e/
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2000-10-02 19:36:32 | Re: libpq PGHOST |
Previous Message | Bruce Momjian | 2000-10-02 17:32:54 | Re: grant/revoke bug with delete/update |