我需要在postgresql 12实例上启用pgcrypto。
我启用了分机,并检查了它是否正常:
postgres=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
postgres=# SELECT digest('blah', 'sha256');
digest
--------------------------------------------------------------------
\x8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52
(1 row)我遵循了我读到的命令:
postgres=# GRANT EXECUTE ON FUNCTION digest(bytea,text) TO normaluser;
GRANT
postgres=# GRANT EXECUTE ON FUNCTION digest(text,text) TO normaluser;
GRANT可悲的是,仍然没有办法在“正常用户”的情况下使用该功能。
normaluser@planck:5432/cryptodb> SELECT digest('blah', 'sha256');
ERROR: 42883: function digest(unknown, unknown) does not exist
LINE 1: SELECT digest('blah', 'sha256');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
LOCATION: ParseFuncOrColumn, parse_func.c:631
Time: 52,065 ms欢迎任何提示,谢谢:)
发布于 2021-01-13 15:50:06
在这个问题中,您可以看到我在创建扩展时作为超级用户postgres连接,而不是连接到cryptodb user normaluser使用的数据库中。所以我用postgres连接到数据库postgres,现在normaluser可以在cryptodb上下文中使用pgcrypto函数digest。
TL;DR;:在CREATE EXTENSION pgcrypto;之前连接到正确的数据库
https://stackoverflow.com/questions/65700716
复制相似问题