plluau

Lua 程序语言(不受信任的)

概览

扩展包名版本分类许可证语言
pllua2.0.12LANGMITC
ID扩展名BinLibLoadCreateTrustReloc模式
3020plluapg_catalog
3021hstore_pllua-
3030plluaupg_catalog
3031hstore_plluaupg_catalog
相关扩展plperlu plpgsql plpython3u plv8 pljava pltclu
下游依赖hstore_plluau

missing pg12-15 on el.aarch64

版本

类型仓库版本PG 大版本包名依赖
EXTPGDG2.0.121817161514pllua-
RPMPGDG2.0.121817161514pllua_$v-
DEBPGDG2.0.121817161514postgresql-$v-pllua-
OS / PGPG18PG17PG16PG15PG14
el8.x86_64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG 2.0.11PGDG 2.0.11
el8.aarch64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG MISSPGDG MISS
el9.x86_64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG 2.0.11PGDG 2.0.11
el9.aarch64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG MISSPGDG MISS
el10.x86_64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
el10.aarch64PGDG MISSPGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d12.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d12.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d13.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
d13.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u22.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u22.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u24.x86_64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12
u24.aarch64PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12PGDG 2.0.12

安装

您可以直接安装 pllua 扩展包的预置二进制包,首先确保 PGDG 仓库已经添加并启用:

pig repo add pgdg -u          # 添加 PGDG 仓库并更新缓存

使用 pig 或者是 apt/yum/dnf 安装扩展:

pig install pllua;          # 当前活跃 PG 版本安装
pig ext install -y pllua -v 18  # PG 18
pig ext install -y pllua -v 17  # PG 17
pig ext install -y pllua -v 16  # PG 16
pig ext install -y pllua -v 15  # PG 15
pig ext install -y pllua -v 14  # PG 14
dnf install -y pllua_18       # PG 18
dnf install -y pllua_17       # PG 17
dnf install -y pllua_16       # PG 16
dnf install -y pllua_15       # PG 15
dnf install -y pllua_14       # PG 14
apt install -y postgresql-18-pllua   # PG 18
apt install -y postgresql-17-pllua   # PG 17
apt install -y postgresql-16-pllua   # PG 16
apt install -y postgresql-15-pllua   # PG 15
apt install -y postgresql-14-pllua   # PG 14

创建扩展

CREATE EXTENSION plluau;

用法

plluau: Lua 不可信过程语言

plluaupllua 的不可信变体,允许 Lua 函数访问文件系统、加载任意模块,以及执行在可信版本中受限的操作。

CREATE EXTENSION plluau;

创建函数

CREATE FUNCTION read_file(path text) RETURNS text LANGUAGE plluau AS $$
  local f = io.open(path, "r")
  if f then
    local content = f:read("*a")
    f:close()
    return content
  end
  return nil
$$;

与 pllua(可信版本)的区别

功能pllua(可信)plluau(不可信)
文件 I/O受限完全访问
模块加载仅白名单无限制
操作系统访问
适用于用户自定义函数管理员/超级用户函数

与 pllua 相同的 API

plluau 共享与 pllua 相同的 SPI 接口、触发器支持、集合返回函数和数据类型处理。所有 SPI 函数(spi.executespi.preparespi.rows)、基于协程的集合返回以及触发器函数的工作方式完全相同。

CREATE FUNCTION run_command(cmd text) RETURNS text LANGUAGE plluau AS $$
  local handle = io.popen(cmd)
  local result = handle:read("*a")
  handle:close()
  return result
$$;

初始化

通过 GUC 参数配置(仅限超级用户):

SET pllua.on_untrusted_init = 'myvar = {}';

由于 plluau 提供的访问权限不受限制,只有超级用户才能创建 plluau 函数。


最后修改 2026-03-12: update extension pages (f579993)