pg_variables

pg_variables

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

Overview

ID Extension Package Version Category License Language
2820
pg_variables
pg_variables
1.2.5
FEAT
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d-r
No
Yes
No
Yes
yes
no
Relationships
See Also
session_variable
orafce
plisql

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pg_variables_18 1.2.5 el8.x86_64 pigsty 35.5 KiB pg_variables_18-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_18 1.2.5 el8.aarch64 pigsty 34.0 KiB pg_variables_18-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_18 1.2.5 el9.x86_64 pigsty 34.7 KiB pg_variables_18-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_18 1.2.5 el9.aarch64 pigsty 33.6 KiB pg_variables_18-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_18 1.2.5 el10.x86_64 pigsty 35.4 KiB pg_variables_18-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_18 1.2.5 el10.aarch64 pigsty 34.4 KiB pg_variables_18-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-18-pg-variables 1.2.5 d12.x86_64 pigsty 60.0 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-18-pg-variables 1.2.5 d12.aarch64 pigsty 59.7 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-18-pg-variables 1.2.5 d13.x86_64 pigsty 60.2 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-18-pg-variables 1.2.5 d13.aarch64 pigsty 59.8 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-18-pg-variables 1.2.5 u22.x86_64 pigsty 65.5 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-18-pg-variables 1.2.5 u22.aarch64 pigsty 65.4 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-18-pg-variables 1.2.5 u24.x86_64 pigsty 63.1 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-18-pg-variables 1.2.5 u24.aarch64 pigsty 63.4 KiB postgresql-18-pg-variables_1.2.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_variables_17 1.2.5 el8.x86_64 pigsty 35.4 KiB pg_variables_17-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_17 1.2.5 el8.aarch64 pigsty 33.9 KiB pg_variables_17-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_17 1.2.5 el9.x86_64 pigsty 34.7 KiB pg_variables_17-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_17 1.2.5 el9.aarch64 pigsty 33.4 KiB pg_variables_17-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_17 1.2.5 el10.x86_64 pigsty 35.4 KiB pg_variables_17-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_17 1.2.5 el10.aarch64 pigsty 34.3 KiB pg_variables_17-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-17-pg-variables 1.2.5 d12.x86_64 pigsty 59.8 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-17-pg-variables 1.2.5 d12.aarch64 pigsty 59.8 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-17-pg-variables 1.2.5 d13.x86_64 pigsty 60.0 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-17-pg-variables 1.2.5 d13.aarch64 pigsty 59.9 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-17-pg-variables 1.2.5 u22.x86_64 pigsty 71.1 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-17-pg-variables 1.2.5 u22.aarch64 pigsty 71.0 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-17-pg-variables 1.2.5 u24.x86_64 pigsty 62.9 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-17-pg-variables 1.2.5 u24.aarch64 pigsty 63.6 KiB postgresql-17-pg-variables_1.2.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_variables_16 1.2.5 el8.x86_64 pigsty 35.4 KiB pg_variables_16-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_16 1.2.5 el8.aarch64 pigsty 34.0 KiB pg_variables_16-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_16 1.2.5 el9.x86_64 pigsty 34.7 KiB pg_variables_16-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_16 1.2.5 el9.aarch64 pigsty 33.4 KiB pg_variables_16-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_16 1.2.5 el10.x86_64 pigsty 35.4 KiB pg_variables_16-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_16 1.2.5 el10.aarch64 pigsty 34.3 KiB pg_variables_16-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-16-pg-variables 1.2.5 d12.x86_64 pigsty 59.7 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-16-pg-variables 1.2.5 d12.aarch64 pigsty 59.8 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-16-pg-variables 1.2.5 d13.x86_64 pigsty 59.9 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-16-pg-variables 1.2.5 d13.aarch64 pigsty 59.8 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-16-pg-variables 1.2.5 u22.x86_64 pigsty 70.8 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-16-pg-variables 1.2.5 u22.aarch64 pigsty 70.6 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-16-pg-variables 1.2.5 u24.x86_64 pigsty 62.8 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-16-pg-variables 1.2.5 u24.aarch64 pigsty 63.6 KiB postgresql-16-pg-variables_1.2.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_variables_15 1.2.5 el8.x86_64 pigsty 35.5 KiB pg_variables_15-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_15 1.2.5 el8.aarch64 pigsty 34.0 KiB pg_variables_15-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_15 1.2.5 el9.x86_64 pigsty 35.0 KiB pg_variables_15-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_15 1.2.5 el9.aarch64 pigsty 34.0 KiB pg_variables_15-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_15 1.2.5 el10.x86_64 pigsty 35.5 KiB pg_variables_15-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_15 1.2.5 el10.aarch64 pigsty 34.4 KiB pg_variables_15-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-15-pg-variables 1.2.5 d12.x86_64 pigsty 59.6 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-15-pg-variables 1.2.5 d12.aarch64 pigsty 59.5 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-15-pg-variables 1.2.5 d13.x86_64 pigsty 59.7 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-15-pg-variables 1.2.5 d13.aarch64 pigsty 59.5 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-15-pg-variables 1.2.5 u22.x86_64 pigsty 70.7 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-15-pg-variables 1.2.5 u22.aarch64 pigsty 71.0 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-15-pg-variables 1.2.5 u24.x86_64 pigsty 62.6 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-15-pg-variables 1.2.5 u24.aarch64 pigsty 63.2 KiB postgresql-15-pg-variables_1.2.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pg_variables_14 1.2.5 el8.x86_64 pigsty 35.5 KiB pg_variables_14-1.2.5-1PIGSTY.el8.x86_64.rpm
pg_variables_14 1.2.5 el8.aarch64 pigsty 34.1 KiB pg_variables_14-1.2.5-1PIGSTY.el8.aarch64.rpm
pg_variables_14 1.2.5 el9.x86_64 pigsty 35.1 KiB pg_variables_14-1.2.5-1PIGSTY.el9.x86_64.rpm
pg_variables_14 1.2.5 el9.aarch64 pigsty 34.0 KiB pg_variables_14-1.2.5-1PIGSTY.el9.aarch64.rpm
pg_variables_14 1.2.5 el10.x86_64 pigsty 35.5 KiB pg_variables_14-1.2.5-1PIGSTY.el10.x86_64.rpm
pg_variables_14 1.2.5 el10.aarch64 pigsty 34.5 KiB pg_variables_14-1.2.5-1PIGSTY.el10.aarch64.rpm
postgresql-14-pg-variables 1.2.5 d12.x86_64 pigsty 59.8 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~bookworm_amd64.deb
postgresql-14-pg-variables 1.2.5 d12.aarch64 pigsty 59.6 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~bookworm_arm64.deb
postgresql-14-pg-variables 1.2.5 d13.x86_64 pigsty 59.9 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~trixie_amd64.deb
postgresql-14-pg-variables 1.2.5 d13.aarch64 pigsty 59.6 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~trixie_arm64.deb
postgresql-14-pg-variables 1.2.5 u22.x86_64 pigsty 71.0 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~jammy_amd64.deb
postgresql-14-pg-variables 1.2.5 u22.aarch64 pigsty 71.1 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~jammy_arm64.deb
postgresql-14-pg-variables 1.2.5 u24.x86_64 pigsty 62.8 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~noble_amd64.deb
postgresql-14-pg-variables 1.2.5 u24.aarch64 pigsty 63.4 KiB postgresql-14-pg-variables_1.2.5-1PIGSTY~noble_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

Syntax:

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

Source: README

pg_variables provides session-wide variables for PostgreSQL. Variables are grouped into packages, live only for the current session, and can be configured as transactional or non-transactional.

Basic Behavior

By default, variables are not transactional and are not affected by BEGIN, COMMIT, or ROLLBACK. The optional is_transactional argument on pgv_set() changes that behavior.

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

Transactional example:

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

Packages

Variables are grouped into packages so multiple named variables can coexist and whole groups can be removed together. The README notes that empty packages are deleted automatically.

Core Functions

Scalar and Array Variables

The generic API is:

pgv_set(package text, name text, value anynonarray, is_transactional bool default false)
pgv_get(package text, name text, var_type anynonarray, strict bool default true)

pgv_set(package text, name text, value anyarray, is_transactional bool default false)
pgv_get(package text, name text, var_type anyarray, strict bool default true)

pgv_get() checks both existence and type. If the package or variable is missing, behavior depends on strict.

Record Collections

The README also documents record-oriented operations such as:

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

These functions work with collections of records stored under a package and variable name.

Deprecated Helpers

The project still ships older type-specific helpers like:

  • pgv_set_int() / pgv_get_int()
  • pgv_set_text() / pgv_get_text()
  • pgv_set_numeric() / pgv_get_numeric()
  • pgv_set_timestamp() / pgv_get_timestamp()
  • pgv_set_timestamptz() / pgv_get_timestamptz()
  • pgv_set_date() / pgv_get_date()
  • pgv_set_jsonb() / pgv_get_jsonb()

The README labels these as deprecated in favor of the generic pgv_set() / pgv_get() API.

Last updated on