'br}

'br}

{\

## NAME

pg_virtualenv - Create a throw-away PostgreSQL environment for running regression tests

## SYNOPSIS

pg_virtualenv [-ash -v 'version ...'] [command]

## DESCRIPTION

pg_virtualenv creates a virtual PostgreSQL server environment, and sets environment variables such that command can access the PostgreSQL database server(s). The servers are destroyed when command exits.

The environment variables s-1PGHOSTs0, s-1PGDATABASEs0, s-1PGUSERs0, and s-1PGPASSWORDs0 will be set. Per default, a single new cluster is created on port 5432, using the newest PostgreSQL server version installed. When more clusters are created for other versions, they will use other port numbers.

pg_createcluster is used to create the database clusters. The clusters are named version/regress. To access a cluster, set PGCLUSTER=version/regress. For ease of access, the clusters are also registered in /etc/postgresql-common/pg_service.conf, with the version number as cluster name. Clusters can be accessed by passing the connection string "service=version", e.g. psql service=9.2.

When invoked as root user, the servers and command are run in an unshared mount and network namespace; the servers are created on tmpfses, so actions caused by command in the database do not affect the running system. command can drop privileges as needed, provided the environment variables are passed.

When invoked as non-root user, s-1PG_CLUSTER_CONF_ROOTs0 and s-1PGSYSCONFDIRs0 are set to a temporary directory where all files belonging to the clusters are created.

## OPTIONS

\fB-a\fR 4

Use all PostgreSQL server versions installed.

\fB-v\fR \fIversion ...\fR 4

Use these versions (space-separated list).

\fB-c\fR \fIpg_createcluster options\fR 4

Extra options to pass to pg_createcluster.

\fB-i\fR \fIinitdb options\fR 4

Extra initdb options to pass to pg_createcluster.

\fB-o\fR \fIguc\fR\fB=\fR\fIvalue\fR 4

Configuration option to set in the f(CW*(C`postgresql.conf*(C' file, passed to pg_createcluster.

\fB-s\fR 4

Launch a shell inside the virtual environment when command fails.

\fB-h\fR 4

Show program help.

## EXAMPLE

# pg_virtualenv make check

## NOTES

When run with fakeroot|(1), pg_virtualenv will fall back to the non-root mode of operation. Running *(L"fakeroot pg_virtualenv*(R" as root will fail, though.

## SEE ALSO

initdb|(1), pg_createcluster|(1), unshare|(1).

## AUTHOR

Christoph Berg <myon@debian.org>