hstore_plperl 是一个 contrib 模块,它为 PL/Perl 的 hstore 类型实现了转换,并(作为 hstore_plperlu)为 PL/PerlU 实现转换。
hstore_plperl 已在 PostgreSQL 9.5 中添加。
变更历史
- PostgreSQL 14
- 信任的扩展状态被撤销(提交 7eeb1d98)
- PostgreSQL 13
- PostgreSQL 9.5
- 添加于(提交 cac76582)
示例
使用示例(使用非信任变体 hstore_plperlu 以便能够使用 Data::Dumper 模块)
postgres=# CREATE EXTENSION hstore_plperlu CASCADE; NOTICE: installing required extension "hstore" NOTICE: installing required extension "plperlu" postgres=# CREATE FUNCTION hello_hstore(hstore) RETURNS TEXT TRANSFORM FOR TYPE hstore LANGUAGE plperlu AS $$ my $params = shift; use Data::Dumper; elog(INFO, Dumper($params)); $params->{message} //= 'world'; return sprintf('hello %s', $params->{message}); $$; CREATE FUNCTION postgres=# SELECT hello_hstore('message=>"universe"'); INFO: $VAR1 = { 'message' => 'universe' }; hello_hstore ---------------- hello universe (1 row)
参考资料
- PostgreSQL documentation: hstore
