'br}

'br}

{\

## NAME

pg_wrapper - wrapper for PostgreSQL client commands

## SYNOPSIS

client-program [--cluster version/cluster] [...]

(client-program: psql, createdb, dropuser, and all other client programs installed in f(CW*(C`/usr/lib/postgresql/*(C'versionf(CW*(C`/bin*(C').

## DESCRIPTION

This program is run only as a link to names which correspond to PostgreSQL programs in f(CW*(C`/usr/lib/postgresql/*(C'versionf(CW*(C`/bin*(C'. 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:

1. 4

explicit specification with the --host option

2. 4

explicit specification with the --cluster option

3. 4

if the s-1PGHOSTs0 environment variable is set, no further cluster selection is performed. The default PostgreSQL version and port number (from the command line, the environment variable s-1PGPORTs0, or default 5432) will be used.

4. 4

explicit specification with the s-1PGCLUSTERs0 environment variable

5. 4

matching entry in f(CW*(C`~/.postgresqlrc*(C' (see postgresqlrc|(5)), if that file exists

6. 4

matching entry in f(CW*(C`/etc/postgresql-common/user_clusters*(C' (see user_clusters|(5)), if that file exists

7. 4

If only one local cluster exists, that one will be selected.

8. 4

If several local clusters exist, the one listening on the default port 5432 will be selected.

If none of these rules match, pg_wrapper aborts with an error.

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.

## OPTIONS

\fB--cluster\fR \fIversion\fR\fB/\fR\fIcluster\fR 4

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.

## ENVIRONMENT

\fB\s-1PGCLUSTER\s0\fR 4

If f(CW$PGCLUSTER is 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 f(CW$PGCLUSTER.

\fB\s-1PG_CLUSTER_CONF_ROOT\s0\fR 4

This specifies an alternative base directory for cluster configurations. This is usually f(CW*(C`/etc/postgresql/*(C', 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.

\fB\s-1PGSYSCONFDIR\s0\fR 4

This is the location of PostgreSQL's and postgresql-common's global configuration (e. g. f(CW*(C`pg_service.conf*(C', user_clusters|(5)). The default is f(CW*(C`/etc/postgresql-common/*(C'.

## FILES

stores the default cluster and database for users and groups as set by the administrators.

stores defaults set by the user himself.

## SEE ALSO

user_clusters|(5), postgresqlrc|(5)

## AUTHOR

Martin Pitt <mpitt@debian.org>