无法将hstore扩展程序安装到新创建的架构中。

5
我有一台安装了Postgres 9.5的Ubuntu 18.04计算机。
我的数据库"mydb"已经安装了hstore。当我执行"\dx store"命令时,确实存在。
List of installed extensions
  Name  | Version | Schema |                   Description                    
--------+---------+--------+--------------------------------------------------

hstore | 1.3     | public | data type for storing sets of (key, value) pairs
(1 row)

当我使用特定备份文件进行pg_restore时,一个名为“mydb”的新模式也被创建,但它不包含“hstore”扩展。"\dx"命令的结果相同。hstore已经在我的template1中了。

pg_restore失败并显示错误信息:

pg_restore: [archiver (db)] could not execute query: ERROR: type "hstore" does not exist

请问有谁能指出问题所在吗?

谢谢。

1个回答

3

备份是使用相同版本的PostgreSQL创建的吗? 通常情况下,转储/还原循环假定数据库先前已创建,但是转储应该创建扩展。 您可以搜索备份以查看是否包含创建模式扩展的指令:

     CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA public;
  • you will need to use the pg_restore command to stdout e.g.

    pg_restore mydump.dump|more
    

如果您没有使用公共模式,则还需要检查模式是在扩展之前创建的。

在恢复之前,您可以尝试在mydb模式中创建hstore扩展,方法如下:

     CREATE EXTENSION IF NOT EXISTS hstore WITH SCHEMA mydb;

另外,hstore扩展可能没有正确安装。

    # locate hstore|grep postgresql
    # dpkg -S /path/to/hstore.so

感谢@vinh。正在创建模式,然后是您提到的hstore扩展。关于版本:从数据库版本9.5.15转储,由pg_dump版本9.6.1转储。恢复服务器数据库的版本为9.5.17。 - duduklein
我的转储确实创建了扩展。我也执行了你提到的dpkg命令,但没有任何变化。 - duduklein

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