envvar

pg_envvar : Fetch the value of an environment variable

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
4270
envvar
pg_envvar
1.0.1
UTIL
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
See Also
session_variable
gzip
bzip
zstd
http
pg_net
pg_curl
pgjq

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.0.1
18
17
16
15
14
pg_envvar-
RPM
PIGSTY
1.0.1
18
17
16
15
14
pg_envvar_$v-
DEB
PIGSTY
1.0.1
18
17
16
15
14
postgresql-$v-pg-envvar-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el8.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el9.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el9.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el10.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
el10.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d12.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d12.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d13.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
d13.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u22.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u22.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u24.x86_64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
u24.aarch64
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1
PIGSTY 1.0.1

Source

pig build pkg pg_envvar;		# build rpm/deb

Install

Make sure PGDG and PIGSTY repo available:

pig repo add pgsql -u   # add both repo and update cache

Install this extension with pig:

pig install pg_envvar;		# install via package name, for the active PG version
pig install envvar;		# install by extension name, for the current active PG version

pig install envvar -v 18;   # install for PG 18
pig install envvar -v 17;   # install for PG 17
pig install envvar -v 16;   # install for PG 16
pig install envvar -v 15;   # install for PG 15
pig install envvar -v 14;   # install for PG 14

Create this extension with:

CREATE EXTENSION envvar;

Usage

envvar: Access environment variables from PostgreSQL

Provides a single function to read environment variables from the database server.

Function

get_env(name TEXT) RETURNS TEXT

Returns the value of the specified environment variable set on the database server, or NULL if not set.

Examples

SELECT get_env('PGTZ');
-- UTC

SELECT get_env('HOME');
-- /var/lib/postgresql

SELECT get_env('PATH');
-- /usr/local/sbin:/usr/local/bin:...

SELECT get_env('NONEXISTENT');
-- NULL

Schema Support

You can install the extension into a specific schema:

CREATE SCHEMA env;
CREATE EXTENSION envvar SCHEMA env;

SELECT env.get_env('PGTZ');
Last updated on