我需要pgcrypto
在 postgresql 12 实例上启用。
我启用了扩展并检查它是否正常:
postgres=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
postgres=# SELECT digest('blah', 'sha256');
digest
--------------------------------------------------------------------
\x8b7df143d91c716ecfa5fc1730022f6b421b05cedee8fd52b1fc65a96030ad52
(1 row)
我遵循了我在 SO 上阅读的建议:
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
欢迎任何提示,谢谢:)