pljs
pljs · PL/JS trusted procedural language
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 3011 | pljs | pljs | 1.0.6 | LANG | PostgreSQL | C |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
Packages
| Linux / PG | PG19 | PG18 | PG17 | PG16 | PG15 |
|---|---|---|---|---|---|
| el8.x86_64 | N/A | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| el8.aarch64 | N/A | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| el9.x86_64 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| el9.aarch64 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| el10.x86_64 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| el10.aarch64 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 | PIGSTY 1.0.6 |
| d12.x86_64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| d12.aarch64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| d13.x86_64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| d13.aarch64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u22.x86_64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u22.aarch64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u24.x86_64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u24.aarch64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u26.x86_64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
| u26.aarch64 | PIGSTY 1.0.6 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 | PGDG 1.0.5 |
Source
github.com/plv8/pljs
pljs-1.0.6.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
Sources:
- README.md
- pljs.control
- pljs.sql
- docs/FUNCTIONS.md
- docs/TYPES.md
- docs/CHANGELOG.md
- src/pljs.c
- .github/workflows/build_and_test.yml
pljs 1.0.6 runs PostgreSQL functions in the QuickJS JavaScript engine. The upstream README describes PostgreSQL 14 and later; this release explicitly adds PostgreSQL 19 and its CI matrix covers 16–19. Review the conversion changes below before upgrading existing functions.
Create Functions
A superuser installs the extension into pg_catalog. It creates a trusted procedural language; the extension itself still requires superuser installation and is not relocatable. No shared preload is required.
Functions use ordinary PostgreSQL privileges. pljs_info() returns runtime memory information, but the installation SQL revokes its PUBLIC permission; grant it only where appropriate.
SQL Access and Resources
pljs.execute(sql, args) executes SQL with positional parameters and returns result rows or the affected-row count. pljs.prepare(sql, types) creates a reusable plan; call plan.free() when finished. A plan also supports plan.cursor(args), with fetch(), move() and close() on the cursor.
pljs.subtransaction(callback) runs a callback in a subtransaction, allowing JavaScript to catch its PostgreSQL errors. In 1.0.6 caught PostgreSQL errors expose e.sqlstate; rethrowing the caught object preserves that SQLSTATE. Cursor errors and errors from pljs.return_next() can be caught without silently tearing down the outer SPI connection.
Additional Interfaces
pljs.return_next(row) emits rows from a set-returning function. Return objects must match the declared result columns. pljs.find_function(name) resolves another PLJS function subject to execution permission. pljs.elog(level, message) emits PostgreSQL messages. Trigger functions receive the trigger context and can execute SQL in 1.0.6. Window functions use pljs.get_window_object() for partition positions, row counts, peer comparisons, argument access and partition-local state.
Configuration
The versioned implementation defines pljs.execution_timeout in seconds: default 300, range 1–65536, user-settable. pljs.memory_limit is a superuser setting in MB: default 512, range 64–3096; changing it updates an initialized runtime. pljs.start_proc names a function invoked when the user’s JavaScript context is initialized, subject to execution permission. These are session/server settings; memory limits should be considered per backend, not as a cluster-wide budget.
1.0.6 Upgrade Boundaries
The release fixes cursor and memory safety failures, Linux crashes in localeCompare() and normalize(), composite set-returning results, trigger SQL access and variadic argument forwarding. Replace sessions still using the old library after installing the release. Verify the loaded version with pljs_version(); the source Makefile generates a fresh installation SQL script, so do not assume it provides an arbitrary SQL upgrade path.
Review existing JavaScript for these behavior changes:
byteaarrives asUint8Array, preserving arbitrary bytes. Code that treated it as UTF-8 text must convert deliberately.int8arrives asBigInt. Convert it explicitly before returning JSON, since ordinary JSON serialization rejectsBigInt.- Types without dedicated converters use their own text I/O. Enums,
moneyand OID aliases can now arrive as strings; cast an OID alias tooidin SQL when a numeric OID is required. - Domains follow their base conversions and enforce constraints. A domain over JSON now supplies a parsed value, and a domain over boolean supplies a boolean. Type modifiers are checked on returned composite/trigger columns.
Test affected functions and stored data conversions before replacing an older installation; fixing a converter does not repair data previously altered by it.