首页 > 解决方案 > PostgreSQL 无法生成 uuid 但安装了 uuid-ossp 扩展?

问题描述

postgresql11-server-11.8_2

当我尝试在 idempiere 中添加新客户端时,我收到以下错误消息:

    idempiere Version=7.1.0.202008290007

    Initial Client Setup Process

Do you want to start the Process?

** org.postgresql.util.PSQLException: ERROR: function uuid_generate_v4() does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Where: PL/pgSQL function generate_uuid() line 3 at RETURN

这通常表明数据库中缺少 uuid 扩展名。但这种情况并非如此。

[root@accounting-2 ~ (master)]# sudo -u postgres psql --dbname=idempiere
psql (11.8)
Type "help" for help.

idempiere=# \dx
                            List of installed extensions
   Name    | Version |   Schema   |                   Description                   
-----------+---------+------------+-------------------------------------------------
 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 uuid-ossp | 1.1     | public     | generate universally unique identifiers (UUIDs)

这是什么原因造成的?它是如何固定的?

标签: postgresql

解决方案


我的 postgres 中 \dx 的输出如下所示:

 plpgsql   | 1.0     | pg_catalog | PL/pgSQL procedural language
 uuid-ossp | 1.1     | adempiere  | generate universally unique identifiers (UUIDs)

在您的情况下,它显示 uuid-ossp 安装在公共模式中,而在我的情况下安装在 adempiere 模式中。

请在您的 idempiere 数据库中尝试以下命令:

CREATE EXTENSION "uuid-ossp"

推荐阅读