[GRASSLIST:1001] Re: g.select.pg problem: list OK but refuse to select available database

Glynn Clements glynn.clements at virgin.net
Fri Aug 22 09:12:04 EDT 2003


tlaronde at polynum.org wrote:

> > Note that the g.select.pg program in 5.0.2 (and earlier) doesn't allow
> > you to "undefine" a host. Once you use "g.select.pg host=...", all
> > subsequent connections will be via TCP/IP. You can select a different
> > host, but you can't revert to Unix domain sockets.
> > 
> > To revert to using a Unix domain socket to connect to a local
> > postmaster process, you have to manually delete the PG_HOST entry from
> > the $GISRC file (typically ~/.grassrc5).
> > 
> > This is fixed in the CVS HEAD version, and should be fixed in 5.0.3.
> 
> Thanks for the tip! What had and still puzzle me is that even when the PG_HOST
> is set and postmaster not accepting TCP/IP connections, the listing of the
> databases succeeds but the connection not (the latter is normal, the former
> may be some side effect). Since there is nothing obvious in the g.select.pg
> code (both listdb and getdbname use the same functions) it may be an
> artefact of the PostgreSQL API.

No. getdbname() uses the host from PG_HOST, while listdb() uses the
host from the "host=..." option.

If you use the "host=..." option, PG_HOST will be set from it before
getdbname() is called, so getdbname() and listdb() will use the same
host. However, if you don't use "host=...", getdbname() will use the
existing PG_HOST setting, while listdb() will use NULL (i.e. use a
Unix-domain socket).

The fix simply unsets PG_HOST if no "host=..." option is provided, so
not using "host=..." will revert to using a Unix-domain socket, rather
than leaving the host unchanged (the current behaviour).

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-user mailing list