pg_variables
Overview
| Package | Version | Category | License | Language |
|---|---|---|---|---|
pg_variables | 1.2.5 | FEAT | PostgreSQL | C |
| ID | Extension | Bin | Lib | Load | Create | Trust | Reloc | Schema |
|---|---|---|---|---|---|---|---|---|
| 2820 | pg_variables | No | Yes | No | Yes | No | Yes | - |
| Related | session_variable orafce plisql |
|---|
Release tag 1.2.5 still ships extension SQL version 1.2.
Version
| Type | Repo | Version | PG Ver | Package | Deps |
|---|---|---|---|---|---|
| EXT | PIGSTY | 1.2.5 | 1817161514 | pg_variables | - |
| RPM | PIGSTY | 1.2.5 | 1817161514 | pg_variables_$v | - |
| DEB | PIGSTY | 1.2.5 | 1817161514 | postgresql-$v-pg-variables | - |
Build
You can build the RPM / DEB packages for pg_variables using pig build:
pig build pkg pg_variables # build RPM / DEB packages
Install
You can install pg_variables directly. First, make sure the PGDG and PIGSTY repositories are added and enabled:
pig repo add pgsql -u # Add repo and update cache
Install the extension using pig or apt/yum/dnf:
pig install pg_variables; # Install for current active PG version
pig ext install -y pg_variables -v 18 # PG 18
pig ext install -y pg_variables -v 17 # PG 17
pig ext install -y pg_variables -v 16 # PG 16
pig ext install -y pg_variables -v 15 # PG 15
pig ext install -y pg_variables -v 14 # PG 14
dnf install -y pg_variables_18 # PG 18
dnf install -y pg_variables_17 # PG 17
dnf install -y pg_variables_16 # PG 16
dnf install -y pg_variables_15 # PG 15
dnf install -y pg_variables_14 # PG 14
apt install -y postgresql-18-pg-variables # PG 18
apt install -y postgresql-17-pg-variables # PG 17
apt install -y postgresql-16-pg-variables # PG 16
apt install -y postgresql-15-pg-variables # PG 15
apt install -y postgresql-14-pg-variables # PG 14
Create Extension:
CREATE EXTENSION pg_variables;
Usage
- Sources: README, repository tags, control file
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.
Feedback
Was this page helpful?
Thanks for the feedback! Please let us know how we can improve.
Sorry to hear that. Please let us know how we can improve.