pljs

pljs : PL/JS trusted procedural language

Overview

IDExtensionPackageVersionCategoryLicenseLanguage
3011
pljs
pljs
1.0.5
LANG
PostgreSQL
C
AttributeHas BinaryHas LibraryNeed LoadHas DDLRelocatableTrusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Schemaspg_catalog
See Also
plv8
jsquery
pllua
pg_tle
plpgsql
pg_jsonschema
plperl
plpython3u

with submodules, hot fix with CONFIG_VERSION

Packages

TypeRepoVersionPG Major CompatibilityPackage PatternDependencies
EXT
MIXED
1.0.5
18
17
16
15
14
pljs-
RPM
PIGSTY
1.0.5
18
17
16
15
14
pljs_$v-
DEB
PIGSTY
1.0.5
18
17
16
15
14
postgresql-$v-pljs-
Linux / PGPG18PG17PG16PG15PG14
el8.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el8.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el9.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el9.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el10.x86_64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
el10.aarch64
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
PIGSTY 1.0.5
d12.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d12.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d13.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
d13.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u22.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u22.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u24.x86_64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
u24.aarch64
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PGDG 1.0.5
PackageVersionOSORGSIZEFile URL
pljs_181.0.5el8.x86_64pigsty381.9 KiBpljs_18-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_181.0.5el8.aarch64pigsty349.2 KiBpljs_18-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_181.0.5el9.x86_64pigsty388.2 KiBpljs_18-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_181.0.5el9.aarch64pigsty370.5 KiBpljs_18-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_181.0.5el10.x86_64pigsty413.8 KiBpljs_18-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_181.0.5el10.aarch64pigsty380.1 KiBpljs_18-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-18-pljs1.0.5d12.x86_64pgdg410.1 KiBpostgresql-18-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-18-pljs1.0.5d12.x86_64pigsty409.1 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-18-pljs1.0.5d12.aarch64pgdg375.3 KiBpostgresql-18-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-18-pljs1.0.5d12.aarch64pigsty374.6 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-18-pljs1.0.5d13.x86_64pgdg429.3 KiBpostgresql-18-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-18-pljs1.0.5d13.x86_64pigsty428.3 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-18-pljs1.0.5d13.aarch64pgdg381.8 KiBpostgresql-18-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-18-pljs1.0.5d13.aarch64pigsty380.5 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-18-pljs1.0.5u22.x86_64pgdg407.3 KiBpostgresql-18-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-18-pljs1.0.5u22.x86_64pigsty434.7 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-18-pljs1.0.5u22.aarch64pgdg373.2 KiBpostgresql-18-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-18-pljs1.0.5u22.aarch64pigsty424.5 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-18-pljs1.0.5u24.x86_64pgdg408.6 KiBpostgresql-18-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-18-pljs1.0.5u24.x86_64pigsty432.1 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-18-pljs1.0.5u24.aarch64pgdg376.9 KiBpostgresql-18-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-18-pljs1.0.5u24.aarch64pigsty422.6 KiBpostgresql-18-pljs_1.0.5-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pljs_171.0.5el8.x86_64pigsty381.7 KiBpljs_17-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_171.0.5el8.aarch64pigsty349.3 KiBpljs_17-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_171.0.5el9.x86_64pigsty388.1 KiBpljs_17-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_171.0.5el9.aarch64pigsty370.4 KiBpljs_17-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_171.0.5el10.x86_64pigsty413.6 KiBpljs_17-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_171.0.5el10.aarch64pigsty379.4 KiBpljs_17-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-17-pljs1.0.5d12.x86_64pgdg410.0 KiBpostgresql-17-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-17-pljs1.0.5d12.x86_64pigsty408.8 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-17-pljs1.0.5d12.aarch64pgdg375.2 KiBpostgresql-17-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-17-pljs1.0.5d12.aarch64pigsty373.9 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-17-pljs1.0.5d13.x86_64pgdg429.3 KiBpostgresql-17-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-17-pljs1.0.5d13.x86_64pigsty427.8 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-17-pljs1.0.5d13.aarch64pgdg381.7 KiBpostgresql-17-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-17-pljs1.0.5d13.aarch64pigsty380.7 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-17-pljs1.0.5u22.x86_64pgdg422.9 KiBpostgresql-17-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-17-pljs1.0.5u22.x86_64pigsty450.8 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-17-pljs1.0.5u22.aarch64pgdg389.6 KiBpostgresql-17-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-17-pljs1.0.5u22.aarch64pigsty440.0 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-17-pljs1.0.5u24.x86_64pgdg407.9 KiBpostgresql-17-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-17-pljs1.0.5u24.x86_64pigsty431.6 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-17-pljs1.0.5u24.aarch64pgdg375.8 KiBpostgresql-17-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-17-pljs1.0.5u24.aarch64pigsty422.4 KiBpostgresql-17-pljs_1.0.5-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pljs_161.0.5el8.x86_64pigsty381.8 KiBpljs_16-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_161.0.5el8.aarch64pigsty349.2 KiBpljs_16-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_161.0.5el9.x86_64pigsty388.0 KiBpljs_16-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_161.0.5el9.aarch64pigsty370.6 KiBpljs_16-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_161.0.5el10.x86_64pigsty413.5 KiBpljs_16-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_161.0.5el10.aarch64pigsty379.5 KiBpljs_16-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-16-pljs1.0.5d12.x86_64pgdg410.0 KiBpostgresql-16-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-16-pljs1.0.5d12.x86_64pigsty408.8 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-16-pljs1.0.5d12.aarch64pgdg375.2 KiBpostgresql-16-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-16-pljs1.0.5d12.aarch64pigsty374.9 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-16-pljs1.0.5d13.x86_64pgdg429.1 KiBpostgresql-16-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-16-pljs1.0.5d13.x86_64pigsty427.8 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-16-pljs1.0.5d13.aarch64pgdg381.8 KiBpostgresql-16-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-16-pljs1.0.5d13.aarch64pigsty380.8 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-16-pljs1.0.5u22.x86_64pgdg421.7 KiBpostgresql-16-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-16-pljs1.0.5u22.x86_64pigsty449.2 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-16-pljs1.0.5u22.aarch64pgdg387.7 KiBpostgresql-16-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-16-pljs1.0.5u22.aarch64pigsty439.1 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-16-pljs1.0.5u24.x86_64pgdg408.0 KiBpostgresql-16-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-16-pljs1.0.5u24.x86_64pigsty431.7 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-16-pljs1.0.5u24.aarch64pgdg375.9 KiBpostgresql-16-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-16-pljs1.0.5u24.aarch64pigsty422.5 KiBpostgresql-16-pljs_1.0.5-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pljs_151.0.5el8.x86_64pigsty382.4 KiBpljs_15-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_151.0.5el8.aarch64pigsty349.6 KiBpljs_15-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_151.0.5el9.x86_64pigsty389.2 KiBpljs_15-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_151.0.5el9.aarch64pigsty372.4 KiBpljs_15-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_151.0.5el10.x86_64pigsty414.1 KiBpljs_15-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_151.0.5el10.aarch64pigsty381.2 KiBpljs_15-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-15-pljs1.0.5d12.x86_64pgdg409.9 KiBpostgresql-15-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-15-pljs1.0.5d12.x86_64pigsty408.6 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-15-pljs1.0.5d12.aarch64pgdg375.5 KiBpostgresql-15-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-15-pljs1.0.5d12.aarch64pigsty374.3 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-15-pljs1.0.5d13.x86_64pgdg429.4 KiBpostgresql-15-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-15-pljs1.0.5d13.x86_64pigsty428.6 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-15-pljs1.0.5d13.aarch64pgdg381.9 KiBpostgresql-15-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-15-pljs1.0.5d13.aarch64pigsty380.8 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-15-pljs1.0.5u22.x86_64pgdg421.9 KiBpostgresql-15-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-15-pljs1.0.5u22.x86_64pigsty449.6 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-15-pljs1.0.5u22.aarch64pgdg388.0 KiBpostgresql-15-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-15-pljs1.0.5u22.aarch64pigsty439.3 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-15-pljs1.0.5u24.x86_64pgdg408.1 KiBpostgresql-15-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-15-pljs1.0.5u24.x86_64pigsty432.0 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-15-pljs1.0.5u24.aarch64pgdg376.5 KiBpostgresql-15-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-15-pljs1.0.5u24.aarch64pigsty423.0 KiBpostgresql-15-pljs_1.0.5-1PIGSTY~noble_arm64.deb
PackageVersionOSORGSIZEFile URL
pljs_141.0.5el8.x86_64pigsty382.4 KiBpljs_14-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_141.0.5el8.aarch64pigsty349.6 KiBpljs_14-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_141.0.5el9.x86_64pigsty388.8 KiBpljs_14-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_141.0.5el9.aarch64pigsty372.2 KiBpljs_14-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_141.0.5el10.x86_64pigsty414.2 KiBpljs_14-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_141.0.5el10.aarch64pigsty381.1 KiBpljs_14-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-14-pljs1.0.5d12.x86_64pgdg410.2 KiBpostgresql-14-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-14-pljs1.0.5d12.x86_64pigsty409.0 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-14-pljs1.0.5d12.aarch64pgdg375.5 KiBpostgresql-14-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-14-pljs1.0.5d12.aarch64pigsty374.2 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-14-pljs1.0.5d13.x86_64pgdg429.4 KiBpostgresql-14-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-14-pljs1.0.5d13.x86_64pigsty428.7 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-14-pljs1.0.5d13.aarch64pgdg381.7 KiBpostgresql-14-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-14-pljs1.0.5d13.aarch64pigsty381.6 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-14-pljs1.0.5u22.x86_64pgdg422.1 KiBpostgresql-14-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-14-pljs1.0.5u22.x86_64pigsty450.1 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-14-pljs1.0.5u22.aarch64pgdg388.1 KiBpostgresql-14-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-14-pljs1.0.5u22.aarch64pigsty439.6 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-14-pljs1.0.5u24.x86_64pgdg408.2 KiBpostgresql-14-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-14-pljs1.0.5u24.x86_64pigsty432.2 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-14-pljs1.0.5u24.aarch64pgdg376.6 KiBpostgresql-14-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-14-pljs1.0.5u24.aarch64pigsty423.0 KiBpostgresql-14-pljs_1.0.5-1PIGSTY~noble_arm64.deb

Source

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

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

Create this extension with:

CREATE EXTENSION pljs;

Usage

pljs: PL/JavaScript trusted procedural language

pljs enables writing PostgreSQL functions in JavaScript using the QuickJS engine.

CREATE EXTENSION pljs;
DO $$ pljs.elog(NOTICE, "Hello, World!") $$ LANGUAGE pljs;

Create Functions

CREATE FUNCTION pljs_add(a int, b int) RETURNS int AS $$
  return a + b;
$$ LANGUAGE pljs;

SELECT pljs_add(1, 2);  -- 3

Database Access

CREATE FUNCTION get_users() RETURNS SETOF json AS $$
  var rows = pljs.execute('SELECT * FROM users');
  for (var i = 0; i < rows.length; i++) {
    pljs.return_next(JSON.stringify(rows[i]));
  }
$$ LANGUAGE pljs;

Execute with arguments:

var rows = pljs.execute('SELECT * FROM tbl WHERE id = $1', [42]);
var affected = pljs.execute('DELETE FROM tbl WHERE price > $1', [1000]);

Prepared Statements

var plan = pljs.prepare('SELECT * FROM tbl WHERE col = $1', ['int']);
var rows = plan.execute([1]);
plan.free();

Cursors

var plan = pljs.prepare('SELECT * FROM tbl WHERE col = $1', ['int']);
var cursor = plan.cursor([1]);
var row;
while (row = cursor.fetch()) {
    // process row
}
cursor.close();
plan.free();

Subtransactions

try {
  pljs.subtransaction(function() {
    pljs.execute("INSERT INTO tbl VALUES(1)");
    pljs.execute("INSERT INTO tbl VALUES(1/0)"); // error - rolls back
  });
} catch(e) {
  // handle error
}

Logging

pljs.elog(DEBUG1, 'debug message');
pljs.elog(NOTICE, 'notice message');
pljs.elog(WARNING, 'warning message');
pljs.elog(ERROR, 'error message');

Find Other PLJS Functions

CREATE FUNCTION callee(a int) RETURNS int AS $$ return a * a $$ LANGUAGE pljs;
CREATE FUNCTION caller(a int, t int) RETURNS int AS $$
  var func = pljs.find_function("callee");
  return func(a);
$$ LANGUAGE pljs;

Window Functions

CREATE FUNCTION my_window_func(val int) RETURNS int AS $$
  var winobj = pljs.get_window_object();
  var pos = winobj.get_current_position();
  var total = winobj.get_partition_row_count();
  return winobj.get_func_arg_in_current(0);
$$ LANGUAGE pljs WINDOW;

Window object methods: get_current_position(), get_partition_row_count(), set_mark_position(pos), rows_are_peers(pos1, pos2), get_func_arg_in_partition(argno, relpos, seektype, mark_pos), get_func_arg_in_frame(argno, relpos, seektype, mark_pos), get_func_arg_in_current(argno), get_partition_local(), set_partition_local(obj).

Utility Functions

SELECT pljs_info();     -- memory and stack usage as JSON
SELECT pljs_version();  -- extension version
Last updated on