plv8
PL/JavaScript (v8) 可信过程程序语言
概览
| 扩展包名 | 版本 | 分类 | 许可证 | 语言 |
|---|---|---|---|---|
plv8 | 3.2.4 | LANG | PostgreSQL | C++ |
| ID | 扩展名 | Bin | Lib | Load | Create | Trust | Reloc | 模式 |
|---|---|---|---|---|---|---|---|---|
| 3010 | plv8 | 否 | 是 | 否 | 是 | 否 | 否 | pg_catalog |
| 相关扩展 | plpgsql pg_jsonschema jsquery plperl plpython3u pg_tle pllua plluau |
|---|
版本
| 类型 | 仓库 | 版本 | PG 大版本 | 包名 | 依赖 |
|---|---|---|---|---|---|
| EXT | PIGSTY | 3.2.4 | 1817161514 | plv8 | - |
| RPM | PIGSTY | 3.2.4 | 1817161514 | plv8_$v | - |
| DEB | PIGSTY | 3.2.4 | 1817161514 | postgresql-$v-plv8 | - |
| OS / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 3.2.4 el8.x86_64.pg18 : plv8_18 plv8_18-3.2.4-1PIGSTY.el8.x86_64.rpm
| PIGSTY 3.2.4 el8.x86_64.pg17 : plv8_17 plv8_17-3.2.4-1PIGSTY.el8.x86_64.rpm
| PIGSTY 3.2.4 el8.x86_64.pg16 : plv8_16 plv8_16-3.2.4-1PIGSTY.el8.x86_64.rpm
| PIGSTY 3.2.4 el8.x86_64.pg15 : plv8_15 plv8_15-3.2.4-1PIGSTY.el8.x86_64.rpm
| PIGSTY 3.2.4 el8.x86_64.pg14 : plv8_14 plv8_14-3.2.4-1PIGSTY.el8.x86_64.rpm
|
| el8.aarch64 | PIGSTY 3.2.4 el8.aarch64.pg18 : plv8_18 plv8_18-3.2.4-1PIGSTY.el8.aarch64.rpm
| PIGSTY 3.2.4 el8.aarch64.pg17 : plv8_17 plv8_17-3.2.4-1PIGSTY.el8.aarch64.rpm
| PIGSTY 3.2.4 el8.aarch64.pg16 : plv8_16 plv8_16-3.2.4-1PIGSTY.el8.aarch64.rpm
| PIGSTY 3.2.4 el8.aarch64.pg15 : plv8_15 plv8_15-3.2.4-1PIGSTY.el8.aarch64.rpm
| PIGSTY 3.2.4 el8.aarch64.pg14 : plv8_14 plv8_14-3.2.4-1PIGSTY.el8.aarch64.rpm
|
| el9.x86_64 | PIGSTY 3.2.4 el9.x86_64.pg18 : plv8_18 plv8_18-3.2.4-1PIGSTY.el9.x86_64.rpm
| PIGSTY 3.2.4 el9.x86_64.pg17 : plv8_17 plv8_17-3.2.4-1PIGSTY.el9.x86_64.rpm
| PIGSTY 3.2.4 el9.x86_64.pg16 : plv8_16 plv8_16-3.2.4-1PIGSTY.el9.x86_64.rpm
| PIGSTY 3.2.4 el9.x86_64.pg15 : plv8_15 plv8_15-3.2.4-1PIGSTY.el9.x86_64.rpm
| PIGSTY 3.2.4 el9.x86_64.pg14 : plv8_14 plv8_14-3.2.4-1PIGSTY.el9.x86_64.rpm
|
| el9.aarch64 | PIGSTY 3.2.4 el9.aarch64.pg18 : plv8_18 plv8_18-3.2.4-1PIGSTY.el9.aarch64.rpm
| PIGSTY 3.2.4 el9.aarch64.pg17 : plv8_17 plv8_17-3.2.4-1PIGSTY.el9.aarch64.rpm
| PIGSTY 3.2.4 el9.aarch64.pg16 : plv8_16 plv8_16-3.2.4-1PIGSTY.el9.aarch64.rpm
| PIGSTY 3.2.4 el9.aarch64.pg15 : plv8_15 plv8_15-3.2.4-1PIGSTY.el9.aarch64.rpm
| PIGSTY 3.2.4 el9.aarch64.pg14 : plv8_14 plv8_14-3.2.4-1PIGSTY.el9.aarch64.rpm
|
| el10.x86_64 | PIGSTY 3.2.4 el10.x86_64.pg18 : plv8_18 plv8_18-3.2.4-2PIGSTY.el10.x86_64.rpm
| PIGSTY 3.2.4 el10.x86_64.pg17 : plv8_17 plv8_17-3.2.4-2PIGSTY.el10.x86_64.rpm
| PIGSTY 3.2.4 el10.x86_64.pg16 : plv8_16 plv8_16-3.2.4-2PIGSTY.el10.x86_64.rpm
| PIGSTY 3.2.4 el10.x86_64.pg15 : plv8_15 plv8_15-3.2.4-2PIGSTY.el10.x86_64.rpm
| PIGSTY 3.2.4 el10.x86_64.pg14 : plv8_14 plv8_14-3.2.4-2PIGSTY.el10.x86_64.rpm
|
| el10.aarch64 | PIGSTY 3.2.4 el10.aarch64.pg18 : plv8_18 plv8_18-3.2.4-2PIGSTY.el10.aarch64.rpm
| PIGSTY 3.2.4 el10.aarch64.pg17 : plv8_17 plv8_17-3.2.4-2PIGSTY.el10.aarch64.rpm
| PIGSTY 3.2.4 el10.aarch64.pg16 : plv8_16 plv8_16-3.2.4-2PIGSTY.el10.aarch64.rpm
| PIGSTY 3.2.4 el10.aarch64.pg15 : plv8_15 plv8_15-3.2.4-2PIGSTY.el10.aarch64.rpm
| PIGSTY 3.2.4 el10.aarch64.pg14 : plv8_14 plv8_14-3.2.4-2PIGSTY.el10.aarch64.rpm
|
| d12.x86_64 | PIGSTY 3.2.4 d12.x86_64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~bookworm_amd64.deb
| PIGSTY 3.2.4 d12.x86_64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~bookworm_amd64.deb
| PIGSTY 3.2.4 d12.x86_64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~bookworm_amd64.deb
| PIGSTY 3.2.4 d12.x86_64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~bookworm_amd64.deb
| PIGSTY 3.2.4 d12.x86_64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~bookworm_amd64.deb
|
| d12.aarch64 | PIGSTY 3.2.4 d12.aarch64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~bookworm_arm64.deb
| PIGSTY 3.2.4 d12.aarch64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~bookworm_arm64.deb
| PIGSTY 3.2.4 d12.aarch64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~bookworm_arm64.deb
| PIGSTY 3.2.4 d12.aarch64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~bookworm_arm64.deb
| PIGSTY 3.2.4 d12.aarch64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~bookworm_arm64.deb
|
| d13.x86_64 | PIGSTY 3.2.4 d13.x86_64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~trixie_amd64.deb
| PIGSTY 3.2.4 d13.x86_64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~trixie_amd64.deb
| PIGSTY 3.2.4 d13.x86_64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~trixie_amd64.deb
| PIGSTY 3.2.4 d13.x86_64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~trixie_amd64.deb
| PIGSTY 3.2.4 d13.x86_64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~trixie_amd64.deb
|
| d13.aarch64 | PIGSTY 3.2.4 d13.aarch64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~trixie_arm64.deb
| PIGSTY 3.2.4 d13.aarch64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~trixie_arm64.deb
| PIGSTY 3.2.4 d13.aarch64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~trixie_arm64.deb
| PIGSTY 3.2.4 d13.aarch64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~trixie_arm64.deb
| PIGSTY 3.2.4 d13.aarch64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~trixie_arm64.deb
|
| u22.x86_64 | PIGSTY 3.2.4 u22.x86_64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~jammy_amd64.deb
| PIGSTY 3.2.4 u22.x86_64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~jammy_amd64.deb
| PIGSTY 3.2.4 u22.x86_64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~jammy_amd64.deb
| PIGSTY 3.2.4 u22.x86_64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~jammy_amd64.deb
| PIGSTY 3.2.4 u22.x86_64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~jammy_amd64.deb
|
| u22.aarch64 | PIGSTY 3.2.4 u22.aarch64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~jammy_arm64.deb
| PIGSTY 3.2.4 u22.aarch64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~jammy_arm64.deb
| PIGSTY 3.2.4 u22.aarch64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~jammy_arm64.deb
| PIGSTY 3.2.4 u22.aarch64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~jammy_arm64.deb
| PIGSTY 3.2.4 u22.aarch64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~jammy_arm64.deb
|
| u24.x86_64 | PIGSTY 3.2.4 u24.x86_64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~noble_amd64.deb
| PIGSTY 3.2.4 u24.x86_64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~noble_amd64.deb
| PIGSTY 3.2.4 u24.x86_64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~noble_amd64.deb
| PIGSTY 3.2.4 u24.x86_64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~noble_amd64.deb
| PIGSTY 3.2.4 u24.x86_64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~noble_amd64.deb
|
| u24.aarch64 | PIGSTY 3.2.4 u24.aarch64.pg18 : postgresql-18-plv8 postgresql-18-plv8_3.2.4-1PIGSTY~noble_arm64.deb
| PIGSTY 3.2.4 u24.aarch64.pg17 : postgresql-17-plv8 postgresql-17-plv8_3.2.4-1PIGSTY~noble_arm64.deb
| PIGSTY 3.2.4 u24.aarch64.pg16 : postgresql-16-plv8 postgresql-16-plv8_3.2.4-1PIGSTY~noble_arm64.deb
| PIGSTY 3.2.4 u24.aarch64.pg15 : postgresql-15-plv8 postgresql-15-plv8_3.2.4-1PIGSTY~noble_arm64.deb
| PIGSTY 3.2.4 u24.aarch64.pg14 : postgresql-14-plv8 postgresql-14-plv8_3.2.4-1PIGSTY~noble_arm64.deb
|
| u26.x86_64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
| u26.aarch64 | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS | PIGSTY MISS |
构建
您可以使用 pig build 命令构建 plv8 扩展的 RPM / DEB 包:
pig build pkg plv8 # 构建 RPM / DEB 包
安装
您可以直接安装 plv8 扩展包的预置二进制包,首先确保 PGDG 和 PIGSTY 仓库已经添加并启用:
pig repo add pgsql -u # 添加仓库并更新缓存
使用 pig 或者是 apt/yum/dnf 安装扩展:
pig install plv8; # 当前活跃 PG 版本安装
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 plv8;
用法
来源:README,Docs site,Built-ins,Runtime configuration,Tag v3.2.4
plv8 是 PostgreSQL 的 trusted JavaScript procedural language,由 V8 引擎驱动。上游当前将扩展标记为 v3.2.4;Pigsty 的 3.2.4-2 包版本只是打包修订,不代表新的上游扩展发布。
基本使用
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;
常用 built-ins
plv8.elog(level, ...):输出 PostgreSQL 日志或客户端消息。plv8.execute(sql [, args]):执行 SQL,并返回结果行或受影响行数。plv8.prepare(...)、PreparedPlan.execute()、PreparedPlan.cursor():提供预编译 SPI 访问。plv8.subtransaction(fn):以原子方式执行一组 SPI 操作。plv8.find_function(...):按名称调用另一个 PLV8 函数。plv8.memory_usage():查看当前会话的 V8 heap 使用情况。plv8.run_script(source, name):执行具名脚本文本。
运行时设置
SET plv8.start_proc = 'plv8_init';
SET plv8.execution_timeout = 60;
SET plv8.memory_limit = 512;
plv8.start_procplv8.v8_flagsplv8.execution_timeoutplv8.memory_limit
注意事项
- 当前文档说明支持 PostgreSQL 13 及以上版本。
- 每个 session 都有独立的全局 JavaScript runtime;切换 role 会初始化单独的 runtime context。
plv8.execution_timeout仅在扩展以 execution-timeout 支持编译时生效。