[英]ERROR: permission denied for language c
When creating a function like this with a non-super user I am getting the error below:当使用非超级用户创建这样的 function 时,我收到以下错误:
ERROR: permission denied for language c SQL state: 42501
The function created is:创建的 function 是:
CREATE OR REPLACE FUNCTION dblink_connect (text)
RETURNS text
AS '$libdir/dblink','dblink_connect'
LANGUAGE C STRICT;
But if I wanted to give permission on language C to my non-super user, I am getting the error below: postgres=# grant usage on language c to caixa; ERROR: language "c" is not trusted
但是,如果我想向我的非超级用户授予语言 C 的权限,我会收到以下错误:
postgres=# grant usage on language c to caixa; ERROR: language "c" is not trusted
postgres=# grant usage on language c to caixa; ERROR: language "c" is not trusted
That means, non-super user can't create function with language C?这意味着,非超级用户无法使用语言 C 创建 function? or is there anything else I am doing wrong?
还是我做错了什么?
That's right, according to doc :没错,根据doc :
Only superusers can create functions in untrusted languages
只有超级用户才能使用不受信任的语言创建函数
Quick check:快速检查:
SELECT lanpltrusted FROM pg_language WHERE lanname LIKE 'c';
lanpltrusted
--------------
f
(1 row)
If you really want this, then you could modify pg_language
system catalog ( ALTER LANGUAGE
doesn't have such option):如果你真的想要这个,那么你可以修改
pg_language
系统目录( ALTER LANGUAGE
没有这样的选项):
UPDATE pg_language SET lanpltrusted = true WHERE lanname LIKE 'c';
Per user @Otheus below: the UPDATE statement must be done in the DB where the function will reside.每个用户@Otheus 下面:UPDATE 语句必须在 function 将驻留的数据库中完成。
Instead of setting the language to trusted which is considered bad , and dangerous , you should rather use roles to provide superuser privilege temporarily to the user during the time he manipulates the stored procedures:与其将语言设置为被认为是坏的和危险的,不如使用角色在用户操作存储过程期间临时为用户提供超级用户权限:
as superuser:作为超级用户:
create role dba with superuser noinherit;
grant dba to user;
then logged-in as user you can set role dba
然后以用户身份登录,您可以
set role dba
And then you could create stored procedures in C while you temporarily have the role dba
.然后你可以在 C 中创建存储过程,而你暂时拥有角色
dba
。
reset role;
when you're finished to come back to normal rights.当您完成恢复正常权利时。
More info here: https://dba.stackexchange.com/questions/37336/cannot-create-function-in-plpython3u-permission-denied更多信息在这里:https://dba.stackexchange.com/questions/37336/cannot-create-function-in-plpython3u-permission-denied
In my case for uuid functions in RDS postgres 12.5.在我的情况下,RDS postgres 12.5 中的 uuid 函数。 All I had to do is:
我所要做的就是:
CREATE EXTENSION IF NOT EXISTS "uuid-ossp';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.