PG_VIRTUALENV(1)
π PG_VIRTUALENV π (yes bestie, this is PG_VIRTUALENV(1) β the Debian PostgreSQL infrastructure girlies know)
okay so you found the pg_virtualenv page. section 1. Debian PostgreSQL infrastructure. we're doing this. sit down, hydrate, let's go π
β¨ NAME β¨
pg_virtualenv β makes a whole entire throw-away PostgreSQL environment so you can run regression tests in it and then never think about it again. it's giving disposable. it's giving responsible. π«Ά
π¦ SYNOPSIS π¦
pg_virtualenv [OPTIONS] [-v 'version ...'] [command]
πΈ DESCRIPTION πΈ
So the whole vibe: pg_virtualenv creates a virtual PostgreSQL server environment and sets environment variables so that command can access the PostgreSQL database server(s). And the servers? They get destroyed when command exits. no residue, no mess, no "wait why is there a cluster on my machine from 2019". iconic behaviour honestly β¨
The environment variables PGHOST, PGDATABASE, PGUSER, and PGPASSWORD will be set. Per default, it creates a single new cluster, using the newest PostgreSQL server version installed. That cluster grabs the first available port number starting from 5432, and PGPORT gets set. PGVERSION is set to the PostgreSQL major version number.
Now when you create clusters for more than one version, they're gonna differ in the port number used, and PGPORT and PGVERSION are not set. The clusters are named version/regress. To access a cluster, set PGCLUSTER=version/regress. And for ease of access, the clusters are also registered in /etc/postgresql-common/pg_service.conf, with the version number as the cluster name. So you can reach a cluster by passing the connection string "service=version", like psql service=9.2. cute, right? π
When invoked as root, the clusters are created in /etc/postgresql/ as usual; for other users, PG_CLUSTER_CONF_ROOT and PGSYSCONFDIR are set to a temporary directory where all files belonging to the clusters are created. bestie privileges β¨
And if command fails? You get the tail of the PostgreSQL server log shown. Plus, if gdb is available, the backtrace from any PostgreSQL coredump is shown. that's the "we got you, here's what went wrong" energy. π
π OPTIONS π
-aβ Use all PostgreSQL server versions installed. all of them. every single one. go off. π-vversion ... β Use these versions (space-separated list). you pick, bestie.-cpg_createcluster options β Extra options to pass topg_createcluster.-iinitdb options β Extra initdb options to pass topg_createcluster.-oguc=value β Configuration option to set in thepostgresql.conffile, passed topg_createcluster.-ppackage β Setextension_control_path(extension_destdiron older versions) anddynamic_library_pathin the cluster to enable loading and testing extensions at build-time fromdebian/package/. This is a Debian-specific PostgreSQL patch. π§-sβ Launch a shell inside the virtual environment whencommandfails. debugging main character energy fr fr.-tβ Install clusters in a temporary directory, even when running as root.-hβ Show program help. classic. never not useful. π
π EXAMPLE π
# pg_virtualenv make check
that's it. that's the whole thing. slay. β¨
π NOTES π
When run with fakeroot(1), pg_virtualenv will fall back to the non-root mode of operation. But heads up: running "fakeroot pg_virtualenv" as root will fail, though. so don't do that one. no cap. π
π§ ENVIRONMENT π§
PG_VIRTUALENV_NEWPID=yesβ When non-empty,pg_virtualenvwill re-exec itself usingnewpid(1).PG_VIRTUALENV_UNSHARE=flagsβ When non-empty,pg_virtualenvwill re-exec itself usingunshare(1)using these flags.PGPORT=nβ When set, the value is used for the (single) cluster created.
β COMPATIBILITY β
PGVERSION is set in postgresql-common (>= 219~).
π SEE ALSO π
initdb(1), pg_createcluster(1).
π AUTHOR π
Christoph Berg <myon@debian.org> β thank you for your service, king π«‘
and that's the page, bestie! this one came from Debian, dated 2026-07-28, and yeah, it's PG_VIRTUALENV(1). go make some throw-away clusters, you've got this πβ¨π
π¦ where this page comes from
- ubuntu stonking: postgresql-common 293ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms