pljs

pljs

pljs : PL/JS trusted procedural language

Overview

ID Extension Package Version Category License Language
3011
pljs
pljs
1.0.5
LANG
PostgreSQL
C
Attribute Has Binary Has Library Need Load Has DDL Relocatable Trusted
--s-d--
No
Yes
No
Yes
no
no
Relationships
Schemas pg_catalog
See Also
plv8
jsquery
pllua
pg_tle
plpgsql
pg_jsonschema
plperl
plpython3u

with submodules, hot fix with CONFIG_VERSION

Packages

Type Repo Version PG Major Compatibility Package Pattern Dependencies
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 / PG PG18 PG17 PG16 PG15 PG14
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
Package Version OS ORG SIZE File URL
pljs_18 1.0.5 el8.x86_64 pigsty 381.9 KiB pljs_18-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_18 1.0.5 el8.aarch64 pigsty 349.2 KiB pljs_18-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_18 1.0.5 el9.x86_64 pigsty 388.2 KiB pljs_18-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_18 1.0.5 el9.aarch64 pigsty 370.5 KiB pljs_18-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_18 1.0.5 el10.x86_64 pigsty 413.8 KiB pljs_18-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_18 1.0.5 el10.aarch64 pigsty 380.1 KiB pljs_18-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-18-pljs 1.0.5 d12.x86_64 pgdg 410.1 KiB postgresql-18-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-18-pljs 1.0.5 d12.x86_64 pigsty 409.1 KiB postgresql-18-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-18-pljs 1.0.5 d12.aarch64 pgdg 375.3 KiB postgresql-18-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-18-pljs 1.0.5 d12.aarch64 pigsty 374.6 KiB postgresql-18-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-18-pljs 1.0.5 d13.x86_64 pgdg 429.3 KiB postgresql-18-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-18-pljs 1.0.5 d13.x86_64 pigsty 428.3 KiB postgresql-18-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-18-pljs 1.0.5 d13.aarch64 pgdg 381.8 KiB postgresql-18-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-18-pljs 1.0.5 d13.aarch64 pigsty 380.5 KiB postgresql-18-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-18-pljs 1.0.5 u22.x86_64 pgdg 407.3 KiB postgresql-18-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-18-pljs 1.0.5 u22.x86_64 pigsty 434.7 KiB postgresql-18-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-18-pljs 1.0.5 u22.aarch64 pgdg 373.2 KiB postgresql-18-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-18-pljs 1.0.5 u22.aarch64 pigsty 424.5 KiB postgresql-18-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-18-pljs 1.0.5 u24.x86_64 pgdg 408.6 KiB postgresql-18-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-18-pljs 1.0.5 u24.x86_64 pigsty 432.1 KiB postgresql-18-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-18-pljs 1.0.5 u24.aarch64 pgdg 376.9 KiB postgresql-18-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-18-pljs 1.0.5 u24.aarch64 pigsty 422.6 KiB postgresql-18-pljs_1.0.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pljs_17 1.0.5 el8.x86_64 pigsty 381.7 KiB pljs_17-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_17 1.0.5 el8.aarch64 pigsty 349.3 KiB pljs_17-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_17 1.0.5 el9.x86_64 pigsty 388.1 KiB pljs_17-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_17 1.0.5 el9.aarch64 pigsty 370.4 KiB pljs_17-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_17 1.0.5 el10.x86_64 pigsty 413.6 KiB pljs_17-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_17 1.0.5 el10.aarch64 pigsty 379.4 KiB pljs_17-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-17-pljs 1.0.5 d12.x86_64 pgdg 410.0 KiB postgresql-17-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-17-pljs 1.0.5 d12.x86_64 pigsty 408.8 KiB postgresql-17-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-17-pljs 1.0.5 d12.aarch64 pgdg 375.2 KiB postgresql-17-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-17-pljs 1.0.5 d12.aarch64 pigsty 373.9 KiB postgresql-17-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-17-pljs 1.0.5 d13.x86_64 pgdg 429.3 KiB postgresql-17-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-17-pljs 1.0.5 d13.x86_64 pigsty 427.8 KiB postgresql-17-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-17-pljs 1.0.5 d13.aarch64 pgdg 381.7 KiB postgresql-17-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-17-pljs 1.0.5 d13.aarch64 pigsty 380.7 KiB postgresql-17-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-17-pljs 1.0.5 u22.x86_64 pgdg 422.9 KiB postgresql-17-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-17-pljs 1.0.5 u22.x86_64 pigsty 450.8 KiB postgresql-17-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-17-pljs 1.0.5 u22.aarch64 pgdg 389.6 KiB postgresql-17-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-17-pljs 1.0.5 u22.aarch64 pigsty 440.0 KiB postgresql-17-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-17-pljs 1.0.5 u24.x86_64 pgdg 407.9 KiB postgresql-17-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-17-pljs 1.0.5 u24.x86_64 pigsty 431.6 KiB postgresql-17-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-17-pljs 1.0.5 u24.aarch64 pgdg 375.8 KiB postgresql-17-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-17-pljs 1.0.5 u24.aarch64 pigsty 422.4 KiB postgresql-17-pljs_1.0.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pljs_16 1.0.5 el8.x86_64 pigsty 381.8 KiB pljs_16-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_16 1.0.5 el8.aarch64 pigsty 349.2 KiB pljs_16-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_16 1.0.5 el9.x86_64 pigsty 388.0 KiB pljs_16-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_16 1.0.5 el9.aarch64 pigsty 370.6 KiB pljs_16-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_16 1.0.5 el10.x86_64 pigsty 413.5 KiB pljs_16-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_16 1.0.5 el10.aarch64 pigsty 379.5 KiB pljs_16-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-16-pljs 1.0.5 d12.x86_64 pgdg 410.0 KiB postgresql-16-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-16-pljs 1.0.5 d12.x86_64 pigsty 408.8 KiB postgresql-16-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-16-pljs 1.0.5 d12.aarch64 pgdg 375.2 KiB postgresql-16-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-16-pljs 1.0.5 d12.aarch64 pigsty 374.9 KiB postgresql-16-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-16-pljs 1.0.5 d13.x86_64 pgdg 429.1 KiB postgresql-16-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-16-pljs 1.0.5 d13.x86_64 pigsty 427.8 KiB postgresql-16-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-16-pljs 1.0.5 d13.aarch64 pgdg 381.8 KiB postgresql-16-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-16-pljs 1.0.5 d13.aarch64 pigsty 380.8 KiB postgresql-16-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-16-pljs 1.0.5 u22.x86_64 pgdg 421.7 KiB postgresql-16-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-16-pljs 1.0.5 u22.x86_64 pigsty 449.2 KiB postgresql-16-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-16-pljs 1.0.5 u22.aarch64 pgdg 387.7 KiB postgresql-16-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-16-pljs 1.0.5 u22.aarch64 pigsty 439.1 KiB postgresql-16-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-16-pljs 1.0.5 u24.x86_64 pgdg 408.0 KiB postgresql-16-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-16-pljs 1.0.5 u24.x86_64 pigsty 431.7 KiB postgresql-16-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-16-pljs 1.0.5 u24.aarch64 pgdg 375.9 KiB postgresql-16-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-16-pljs 1.0.5 u24.aarch64 pigsty 422.5 KiB postgresql-16-pljs_1.0.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pljs_15 1.0.5 el8.x86_64 pigsty 382.4 KiB pljs_15-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_15 1.0.5 el8.aarch64 pigsty 349.6 KiB pljs_15-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_15 1.0.5 el9.x86_64 pigsty 389.2 KiB pljs_15-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_15 1.0.5 el9.aarch64 pigsty 372.4 KiB pljs_15-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_15 1.0.5 el10.x86_64 pigsty 414.1 KiB pljs_15-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_15 1.0.5 el10.aarch64 pigsty 381.2 KiB pljs_15-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-15-pljs 1.0.5 d12.x86_64 pgdg 409.9 KiB postgresql-15-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-15-pljs 1.0.5 d12.x86_64 pigsty 408.6 KiB postgresql-15-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-15-pljs 1.0.5 d12.aarch64 pgdg 375.5 KiB postgresql-15-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-15-pljs 1.0.5 d12.aarch64 pigsty 374.3 KiB postgresql-15-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-15-pljs 1.0.5 d13.x86_64 pgdg 429.4 KiB postgresql-15-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-15-pljs 1.0.5 d13.x86_64 pigsty 428.6 KiB postgresql-15-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-15-pljs 1.0.5 d13.aarch64 pgdg 381.9 KiB postgresql-15-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-15-pljs 1.0.5 d13.aarch64 pigsty 380.8 KiB postgresql-15-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-15-pljs 1.0.5 u22.x86_64 pgdg 421.9 KiB postgresql-15-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-15-pljs 1.0.5 u22.x86_64 pigsty 449.6 KiB postgresql-15-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-15-pljs 1.0.5 u22.aarch64 pgdg 388.0 KiB postgresql-15-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-15-pljs 1.0.5 u22.aarch64 pigsty 439.3 KiB postgresql-15-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-15-pljs 1.0.5 u24.x86_64 pgdg 408.1 KiB postgresql-15-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-15-pljs 1.0.5 u24.x86_64 pigsty 432.0 KiB postgresql-15-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-15-pljs 1.0.5 u24.aarch64 pgdg 376.5 KiB postgresql-15-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-15-pljs 1.0.5 u24.aarch64 pigsty 423.0 KiB postgresql-15-pljs_1.0.5-1PIGSTY~noble_arm64.deb
Package Version OS ORG SIZE File URL
pljs_14 1.0.5 el8.x86_64 pigsty 382.4 KiB pljs_14-1.0.5-1PIGSTY.el8.x86_64.rpm
pljs_14 1.0.5 el8.aarch64 pigsty 349.6 KiB pljs_14-1.0.5-1PIGSTY.el8.aarch64.rpm
pljs_14 1.0.5 el9.x86_64 pigsty 388.8 KiB pljs_14-1.0.5-1PIGSTY.el9.x86_64.rpm
pljs_14 1.0.5 el9.aarch64 pigsty 372.2 KiB pljs_14-1.0.5-1PIGSTY.el9.aarch64.rpm
pljs_14 1.0.5 el10.x86_64 pigsty 414.2 KiB pljs_14-1.0.5-1PIGSTY.el10.x86_64.rpm
pljs_14 1.0.5 el10.aarch64 pigsty 381.1 KiB pljs_14-1.0.5-1PIGSTY.el10.aarch64.rpm
postgresql-14-pljs 1.0.5 d12.x86_64 pgdg 410.2 KiB postgresql-14-pljs_1.0.5-1.pgdg12+1_amd64.deb
postgresql-14-pljs 1.0.5 d12.x86_64 pigsty 409.0 KiB postgresql-14-pljs_1.0.5-1PIGSTY~bookworm_amd64.deb
postgresql-14-pljs 1.0.5 d12.aarch64 pgdg 375.5 KiB postgresql-14-pljs_1.0.5-1.pgdg12+1_arm64.deb
postgresql-14-pljs 1.0.5 d12.aarch64 pigsty 374.2 KiB postgresql-14-pljs_1.0.5-1PIGSTY~bookworm_arm64.deb
postgresql-14-pljs 1.0.5 d13.x86_64 pgdg 429.4 KiB postgresql-14-pljs_1.0.5-1.pgdg13+1_amd64.deb
postgresql-14-pljs 1.0.5 d13.x86_64 pigsty 428.7 KiB postgresql-14-pljs_1.0.5-1PIGSTY~trixie_amd64.deb
postgresql-14-pljs 1.0.5 d13.aarch64 pgdg 381.7 KiB postgresql-14-pljs_1.0.5-1.pgdg13+1_arm64.deb
postgresql-14-pljs 1.0.5 d13.aarch64 pigsty 381.6 KiB postgresql-14-pljs_1.0.5-1PIGSTY~trixie_arm64.deb
postgresql-14-pljs 1.0.5 u22.x86_64 pgdg 422.1 KiB postgresql-14-pljs_1.0.5-1.pgdg22.04+1_amd64.deb
postgresql-14-pljs 1.0.5 u22.x86_64 pigsty 450.1 KiB postgresql-14-pljs_1.0.5-1PIGSTY~jammy_amd64.deb
postgresql-14-pljs 1.0.5 u22.aarch64 pgdg 388.1 KiB postgresql-14-pljs_1.0.5-1.pgdg22.04+1_arm64.deb
postgresql-14-pljs 1.0.5 u22.aarch64 pigsty 439.6 KiB postgresql-14-pljs_1.0.5-1PIGSTY~jammy_arm64.deb
postgresql-14-pljs 1.0.5 u24.x86_64 pgdg 408.2 KiB postgresql-14-pljs_1.0.5-1.pgdg24.04+1_amd64.deb
postgresql-14-pljs 1.0.5 u24.x86_64 pigsty 432.2 KiB postgresql-14-pljs_1.0.5-1PIGSTY~noble_amd64.deb
postgresql-14-pljs 1.0.5 u24.aarch64 pgdg 376.6 KiB postgresql-14-pljs_1.0.5-1.pgdg24.04+1_arm64.deb
postgresql-14-pljs 1.0.5 u24.aarch64 pigsty 423.0 KiB postgresql-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