如何安装pgcrypto?

Len*_*art 4 postgresql linux

在尝试回答从现有字符串列创建整数 id 列(整数编码?)时,结果发现我需要我自己的 postgres 版本来使用。我已经安装了一个不错的 postgres 版本:

stack=# select version();
                                                version                         

--------------------------------------------------------------------------------
------------------------
 PostgreSQL 11.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 9.1.1 20190503 (R
ed Hat 9.1.1-1), 64-bit
Run Code Online (Sandbox Code Playgroud)

但它没有 pgcrypto 模块:

stack=# CREATE EXTENSION pgcrypto;
ERROR:  could not open extension control file "/usr/pgsql-11/share/extension/pgcrypto.control": No such file or directory
Run Code Online (Sandbox Code Playgroud)

所以我安装了:

sudo dnf install postgresql-contrib 
Run Code Online (Sandbox Code Playgroud)

但我仍然遇到同样的错误。如果我查看:

]$ ls /usr/pgsql-11/share/extension/
plpgsql--1.0.sql  plpgsql.control  plpgsql--unpackaged--1.0.sql
Run Code Online (Sandbox Code Playgroud)

我还需要安装其他软件包吗,或者我还缺少其他东西吗?

更新:

rpm -qa postgresql\* 
postgresql-contrib-11.3-1.fc30.x86_64 
postgresql11-11.4-1PGDG.f30.x86_64 
postgresql-11.3-1.fc30.x86_64 
postgresql11-server-11.4-1PGDG.f30.x86_64 
postgresql11-libs-11.4-1PGDG.f30.x86_64 
Run Code Online (Sandbox Code Playgroud)

我收到 dnf install postgresql11-contrib 错误:

[...] 无法同步存储库“fedora-modular”的缓存错误:无法同步存储库“fedora-modular”的缓存

pdgd 似乎是最新可用的:

rpm -qa | grep pgdg-fedora
pgdg-fedora-repo-42.0-4.noarch
Run Code Online (Sandbox Code Playgroud)

更新2:

显然有些东西暂时停止了,现在它可以:

sudo dnf install postgresql11-contrib
[...]
Downloading Packages:
postgresql11-contrib-11.4-1PGDG.f30.x86_64.rpm  285 kB/s | 602 kB     00:02    

rpm -qa postgresql\*
postgresql-contrib-11.3-1.fc30.x86_64
postgresql11-11.4-1PGDG.f30.x86_64
postgresql11-contrib-11.4-1PGDG.f30.x86_64
postgresql-11.3-1.fc30.x86_64
postgresql11-server-11.4-1PGDG.f30.x86_64
postgresql11-libs-11.4-1PGDG.f30.x86_64

stack=# CREATE EXTENSION pgcrypto;
CREATE EXTENSION
Run Code Online (Sandbox Code Playgroud)

Lau*_*lbe 6

contrib是正确的,但您必须为与您正在使用的不同的 PostgreSQL 安装它。

查看安装了哪些软件包:

rpm -qa postgresql\*
Run Code Online (Sandbox Code Playgroud)

很有可能你需要跑步

dnf install postgresql11-contrib
Run Code Online (Sandbox Code Playgroud)