在 Postgres 的 plperl 函数中访问 current_settings 函数

Accessing current_settings function within a plperl function in Postgres

我正在 Postgres 中编写我的第一个 plperl 函数,我需要访问 current_settings() 区域中的一些值(通过使用该调用)——我想知道最好的解决方案是什么这样做是?

在 plpgsql 中我可以做类似的事情:

DECLARE
  cid int;
BEGIN
  select nullif(current_setting('jwt.claims.customerId', true), '') :: int into cid;
END ...

只是想知道在 Perl plperl 脚本中访问 current_setting 等系统函数的等价物..

谢谢!

使用 database access functions 之一,例如:

$rv = spi_exec_query("select nullif(current_setting('jwt.claims.customerId', true), '')::int as cid");
$cid = $rv->{rows}[0]->{cid};