plv8

PL/JavaScript (v8) trusted procedural language

Overview

PackageVersionCategoryLicenseLanguage
plv83.2.4LANGPostgreSQLC++
IDExtensionBinLibLoadCreateTrustRelocSchema
3010plv8NoYesNoYesNoNopg_catalog
Relatedplpgsql pg_jsonschema jsquery plperl plpython3u pg_tle pllua plluau

Version

TypeRepoVersionPG VerPackageDeps
EXTPIGSTY3.2.41817161514plv8-
RPMPIGSTY3.2.41817161514plv8_$v-
DEBPIGSTY3.2.41817161514postgresql-$v-plv8-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64
el8.aarch64
el9.x86_64
el9.aarch64
el10.x86_64
el10.aarch64
d12.x86_64
d12.aarch64
d13.x86_64
d13.aarch64
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
u22.x86_64
u22.aarch64
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
u24.x86_64
u24.aarch64
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4
PIGSTY 3.2.4

Build

You can build the RPM / DEB packages for plv8 using pig build:

pig build pkg plv8         # build RPM / DEB packages

Install

You can install plv8 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 plv8;          # Install for current active PG version
pig ext install -y plv8 -v 18  # PG 18
pig ext install -y plv8 -v 17  # PG 17
pig ext install -y plv8 -v 16  # PG 16
pig ext install -y plv8 -v 15  # PG 15
pig ext install -y plv8 -v 14  # PG 14
dnf install -y plv8_18       # PG 18
dnf install -y plv8_17       # PG 17
dnf install -y plv8_16       # PG 16
dnf install -y plv8_15       # PG 15
dnf install -y plv8_14       # PG 14
apt install -y postgresql-18-plv8   # PG 18
apt install -y postgresql-17-plv8   # PG 17
apt install -y postgresql-16-plv8   # PG 16
apt install -y postgresql-15-plv8   # PG 15
apt install -y postgresql-14-plv8   # PG 14

Create Extension:

CREATE EXTENSION plv8;

Usage

Source: README, Docs site, Built-ins, Runtime configuration, Tag v3.2.4

plv8 is a trusted JavaScript procedural language for PostgreSQL, powered by the V8 engine. Upstream currently tags the extension as v3.2.4; Pigsty’s 3.2.4-2 package version is a packaging revision rather than a new upstream extension release.

Basic use

CREATE EXTENSION plv8;

SELECT plv8_version();
SELECT plv8_info();

DO $$ plv8.elog(NOTICE, plv8.version); $$ LANGUAGE plv8;

CREATE FUNCTION plv8_test(keys text[], vals text[]) RETURNS json AS $$
  let out = {};
  for (let i = 0; i < keys.length; i++) out[keys[i]] = vals[i];
  return out;
$$ LANGUAGE plv8 IMMUTABLE STRICT;

Common built-ins

  • plv8.elog(level, ...): emit PostgreSQL log or client messages.
  • plv8.execute(sql [, args]): run SQL and return rows or affected-row count.
  • plv8.prepare(...), PreparedPlan.execute(), PreparedPlan.cursor(): prepared SPI access.
  • plv8.subtransaction(fn): run a group of SPI operations atomically.
  • plv8.find_function(...): call another PLV8 function by name.
  • plv8.memory_usage(): inspect V8 heap usage for the current session.
  • plv8.run_script(source, name): evaluate named script text.

Runtime settings

SET plv8.start_proc = 'plv8_init';
SET plv8.execution_timeout = 60;
SET plv8.memory_limit = 512;
  • plv8.start_proc
  • plv8.v8_flags
  • plv8.execution_timeout
  • plv8.memory_limit

Caveats

  • Current docs state support for PostgreSQL 13 and above.
  • Each session has its own global JavaScript runtime; switching roles initializes a separate runtime context.
  • plv8.execution_timeout only applies when the extension is compiled with execution-timeout support.

Last Modified 2026-04-19: update extension stub docs (9f178c3)