已安装 pgcrypto 扩展但其功能不可用

use*_*521 6 postgresql

在客户端服务器上我遇到了一个问题 - 我没有创建扩展的权限pgcrypto。因此,服务器管理员为我做的,现在我可以看到pg_available_extensions的是pgcrypto安装(1.1),但它的功能不可用对我来说:

=> select gen_random_uuid();
ERROR:  function gen_random_uuid() does not exist
LINE 1: select gen_random_uuid();
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

此外,我无权删除扩展程序(这可能是出了什么问题的线索?):

=> drop extension pgcrypto;
ERROR:  must be owner of extension pgcrypto
Run Code Online (Sandbox Code Playgroud)

知道出了什么问题以及为什么我看不到pgcrypto功能吗?有权限的东西?

Dan*_*ité 9

几种可能的解释:

  • PostgreSQL 版本早于 9.4。这个函数gen_random_uuid()http://www.postgresql.org/docs/9.4/static/release-9-4.html之前不存在 :

    将 UUID 随机数生成器 gen_random_uuid() 添加到 pgcrypto (Oskari Saarenmaa)

    使用select version();检查版本。

  • 或者它是 9.4+,但扩展是在不在search_pathSQL 会话中的架构中创建的。使用\dxpsql 中的元命令列出已安装的扩展,并检查Schema列。

  • 或者扩展位于 中包含的架构中search_path,但 db 用户没有查看它的权限。授予它:GRANT USAGE ON SCHEMA schema_name TO role_name