Skip to content
pg_variables

pg_variables

pg_variables : Session-scoped variables with scalar, array, and record types

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
2820
pg_variables
pg_variables
1.2.5
FEAT
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
session_variable
orafce
plisql

Release tag 1.2.5 still ships extension SQL version 1.2.

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
PIGSTY
1.2.5
18
17
16
15
14
pg_variables-
RPM
PIGSTY
1.2.5
18
17
16
15
14
pg_variables_$v-
DEB
PIGSTY
1.2.5
18
17
16
15
14
postgresql-$v-pg-variables-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
el8.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
el9.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
el9.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
el10.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
el10.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
d12.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
d12.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
d13.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
d13.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u22.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u22.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u24.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u24.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u26.x86_64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
u26.aarch64
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PIGSTY 1.2.5
PackageVersionOSORGSIZEFile URL
pg_variables_181.2.5el8.x86_64pigsty35.5 KiBpg_variables_18-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_181.2.5el8.aarch64pigsty34.0 KiBpg_variables_18-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_181.2.5el9.x86_64pigsty34.7 KiBpg_variables_18-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_181.2.5el9.aarch64pigsty33.6 KiBpg_variables_18-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_181.2.5el10.x86_64pigsty35.4 KiBpg_variables_18-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_181.2.5el10.aarch64pigsty34.4 KiBpg_variables_18-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-variables1.2.5d12.x86_64pigsty60.0 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-variables1.2.5d12.aarch64pigsty59.7 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-variables1.2.5d13.x86_64pigsty60.2 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-variables1.2.5d13.aarch64pigsty59.8 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-variables1.2.5u22.x86_64pigsty65.5 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-variables1.2.5u22.aarch64pigsty65.4 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-variables1.2.5u24.x86_64pigsty63.1 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-18-pg-variables1.2.5u24.aarch64pigsty63.4 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~noble_arm64.deb
postgresql-18-pg-variables1.2.5u26.x86_64pigsty61.6 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~resolute_amd64.deb
postgresql-18-pg-variables1.2.5u26.aarch64pigsty62.2 KiBpostgresql-18-pg-variables_1.2.5-1PIGSTY~resolute_arm64.deb

Source

pig build pkg pg_variables;		# 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_variables;		# install via package name, for the active PG version

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

Create this extension with:

CREATE EXTENSION pg_variables;

Usage

pg_variables provides session-scoped variables grouped into named packages. Variables live only in the current session and are non-transactional by default unless created with is_transactional := true.

Basic Set And Get

CREATE EXTENSION pg_variables;

SELECT pgv_set('vars', 'int1', 101);
SELECT pgv_get('vars', 'int1', NULL::int);

Transactional variables participate in savepoints and rollbacks:

BEGIN;
SELECT pgv_set('vars', 'trans_int', 101, true);
SAVEPOINT sp1;
SELECT pgv_set('vars', 'trans_int', 102, true);
ROLLBACK TO sp1;
COMMIT;

Core APIs

The README documents generic scalar and array APIs:

  • pgv_set(package, name, value, is_transactional default false)
  • pgv_get(package, name, NULL::type, strict default true)

It also documents record-oriented APIs:

  • pgv_insert()
  • pgv_update()
  • pgv_delete()
  • pgv_select()

Useful administration helpers include pgv_exists(), pgv_remove(), pgv_free(), pgv_list(), and pgv_stats().

Error And Strictness Behavior

pgv_get() checks both existence and type. The README shows that missing packages, missing variables, or mismatched types raise errors unless strict := false, in which case NULL is returned for missing values.

Deprecated Helpers And Version Note

Upstream still ships deprecated type-specific helpers such as pgv_set_int() / pgv_get_int() and pgv_set_jsonb() / pgv_get_jsonb(), but recommends the generic pgv_set() / pgv_get() API.

The repository tag is v1.2.5, while the current pg_variables.control file still declares default_version = '1.2'. That matches the packaging note that the release tag advanced without changing the SQL extension version string.

Last updated on