PGHOST sets the default server name.
- If a non-zero-length string is specified, TCP/IP communication is used.
- Without a host name, libpq will connect using a local Unix domain socket.
+ If it begins with a slash, it is used
+ as the directory for the unix domain socket.
- PGUNIXSOCKET sets the full Unix domain socket
-
file name for communicating with the
Postgres
+ PGUNIXSOCKET sets the Unix domain socket
+
directory for communicating with the
Postgres
backend.
Name of host to connect to.
Using this parameter causes a hostname look-up. See hostaddr.
If it begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
unixsocket
- Full path to Unix-domain socket file to connect to at the server host.
+ Directory for Unix-domain socket file.
PQunixsocket
- Returns the name of the Unix-domain socket of the connection.
+ Returns the directory of the Unix-domain socket of the connection.
char *PQunixsocket(const PGconn *conn)
PGHOST sets the default server name.
-If it beings with a slash, it is used as the path to a unix domain
+If it beings with a slash, it is used as the directory for the unix domain
socket.
-Without a host name, libpq will connect using a local Unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
-k filename
- Specifies the Unix domain socket file name on which the
+ Specifies the directory for Unix domain socket on which the
postmaster is to listen for
connections from client applications. Defaults to the value
of the PGUNIXSOCKET environment variable, or if
PGUNIXSOCKET is not set, then defaults to a
- file in /tmp constructed from the port
- number.
+ file in /tmp.
Specifies the host name of the machine on which the
If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
Specifies the hostname of the machine on which the
is running. If host begins with a slash, it is used
- as the path to a unix domain socket.
+ as the directory for the unix domain socket.
UNIXSOCKET (string)
- Specifies the Unix domain socket file name on which the
+ Specifies the directory of the Unix domain socket on which the
postmaster is to listen for
connections from client applications. Defaults to the value
of the PGUNIXSOCKET environment variable, or if
- PGUNIXSOCKET is not set, then defaults to a
- file in /tmp constructed from the port
- number.
+ PGUNIXSOCKET is not set, then defaults to
+ /tmp.
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pqcomm.h,v 1.45 2000/11/15 18:36:06 petere Exp $
+ * $Id: pqcomm.h,v 1.46 2000/11/22 01:41:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
/* Configure the UNIX socket address for the well known port. */
#if defined(SUN_LEN)
-#define UNIXSOCK_PATH(sun,port,defpath) \
- ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
#define UNIXSOCK_LEN(sun) \
(SUN_LEN(&(sun)))
#else
-#define UNIXSOCK_PATH(sun,port,defpath) \
- ((defpath && defpath[0] != '\0') ? (strncpy((sun).sun_path, defpath, sizeof((sun).sun_path)), (sun).sun_path[sizeof((sun).sun_path)-1] = '\0') : sprintf((sun).sun_path, "/tmp/.s.PGSQL.%d", (port)))
#define UNIXSOCK_LEN(sun) \
(strlen((sun).sun_path)+ offsetof(struct sockaddr_un, sun_path))
#endif
+#define UNIXSOCK_PATH(sun,port,defpath) \
+ (snprintf((sun).sun_path, UNIXSOCK_LEN(sun), "%s/.s.PGSQL.%d", (defpath && *(defpath) != '\0') ? (defpath) : "/tmp", (port)))
+
/*
* We do this because sun_len is in BSD's struct, while others don't.
* We never actually set BSD's sun_len, and I can't think of a