PostgreSQL存在问题

4

我试图将pg_trgm模块加载到PostgreSQL中,但是出了些问题:

$ psql -d simko_development -f /usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql
SET
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:9: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:14: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:19: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:24: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:29: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:38: ERROR:  function similarity_op(text, text) does not exist
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:44: NOTICE:  type "gtrgm" is not yet defined
DETAIL:  Creating a shell type definition.
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:44: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:49: ERROR:  type gtrgm does not exist
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:55: ERROR:  function gtrgm_in(cstring) does not exist
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:61: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:66: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:71: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:76: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:81: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:86: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:91: ERROR:  type gtrgm does not exist
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:105: ERROR:  operator does not exist: text % text
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:111: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:116: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:121: ERROR:  could not access file "$libdir/pg_trgm": No such file or directory
psql:/usr/local/Cellar/postgresql/9.0.2/share/contrib/pg_trgm.sql:132: ERROR:  operator does not exist: text % text
  • Mac OS X 10.6.6(操作系统版本)
  • PostgreSQL 9.0.2(通过Homebrew安装的数据库软件版本)

更多信息:

$ pg_config --sharedir
/usr/local/Cellar/postgresql/9.0.2/share
3个回答

6

我不能帮你处理macOS,但是在Debian-Linux安装中经常会出现相同的问题。一个简单的解决方案是:所需的库位于一个名为postgresql-contrib的单独软件包中,需要额外安装主要的postgresql软件包。


在生产服务器上,我也这样做了,模块成功安装了。在开发机器上,我有所需模块的 contrib 文件夹,但它不起作用。 - Sasha Koss

1

我知道这是一个老问题,但我是通过谷歌找到的,所以其他人也可能会来到这里。

在我的Mac OSX macports安装中,我有两个包含postgresql .so文件的文件夹:

/opt/local/lib/postgresql90/

并且

/usr/local/pgsql-9.0/lib/

看起来我的安装程序在 /opt/local/lib/postgresql90/ 而不是 /usr/local/pgsql-9.0/lib/ 中查找,因此为了安装 pg_trgm,我必须执行以下操作:

sudo ln -s /opt/local/lib/postgresql90/pg_trgm.so /usr/local/pgsql-9.0/lib/

这应该适用于任何未放置在正确位置的 .so 文件。


这个答案帮助我解决了同样的问题;顺便说一下,在我的OSX 10.7 Lion服务器设置中,要创建的符号链接是:sudo ln -s /opt/local/lib/postgresql90/pg_trgm.so /usr/lib/postgresql/;我通过 hotspot 找到了 pg_trm.so,并使用 > pg_config --pkglibdir 命令找到了 .so 文件夹的路径(/usr/lib/postgresql)。 - Franco Rondini

0
重新安装PostgreSQL解决了我的问题。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接