pg_wrapper - Man Page
wrapper for PostgreSQL client commands
client-program [--cluster version/cluster] [...]
(client-program: psql, createdb, dropuser, and all other client programs installed in
This program is run only as a link to names which correspond to PostgreSQL programs in
/bin. It determines the configured cluster and database for the user and calls the appropriate version of the desired program to connect to that cluster and database, supplying any specified options to that command.
The target cluster is selected by the following means, in descending order of precedence:
- explicit specification with the --host option
- explicit specification with the --cluster option
- if the PGHOST environment variable is set, no further cluster selection is performed. The default PostgreSQL version and port number (from the command line, the environment variable PGPORT, or default 5432) will be used.
- explicit specification with the PGCLUSTER environment variable
- matching entry in
~/.postgresqlrc(see postgresqlrc(5)), if that file exists
- matching entry in
/etc/postgresql-common/user_clusters(see user_clusters(5)), if that file exists
- If only one local cluster exists, that one will be selected.
- If several local clusters exist, the one listening on the default port 5432 will be selected.
If none of these rules match, pg_wrapper does not set any environment variables and the program called will likely error out with a message like “could not connect to server: Connection refused”.
For psql, pg_archivecleanup, and pg_isready, pg_wrapper will always use the binary from the newest PostgreSQL version installed, as these are downwards compatible.
- --cluster version/cluster
- --cluster version/host:[port]
cluster is either the name of a local cluster, or takes the form host:port for a remote cluster. If port is left empty (i. e. you just specify host:), it defaults to 5432.
$PGCLUSTERis set, its value (of the form version/cluster) specifies the desired cluster, similar to the --cluster option. However, if --cluster is specified, it overrides the value of
This specifies an alternative base directory for cluster configurations. This is usually
/etc/postgresql/, but for testing/development purposes you can change this to point to e. g. your home directory, so that you can use the postgresql-common tools without root privileges.
This is the location of PostgreSQL's and postgresql-common's global configuration (e. g.
pg_service.conf, user_clusters(5)). The default is
stores the default cluster and database for users and groups as set by the administrators.
stores defaults set by the user himself.
Martin Pitt <email@example.com>
pg_createcluster(1), pg_ctlcluster(1), pg_renamecluster(1), pg_upgradecluster(1), postgresqlrc(5), user_clusters(5).