【问题标题】:AWS RDS PostgreSQL 9.5.4 Extension postgis_tiger_geocoder Missing Soundex?AWS RDS PostgreSQL 9.5.4 扩展 postgis_tiger_geocoder 缺少 Soundex?
【发布时间】:2018-03-05 19:31:36
【问题描述】:

我正在尝试在我们的大型 RDS 实例上安装 AWS“已批准”PostgreSql 扩展,但每次我尝试“创建扩展 postgis_tiger_geocoder”时都会得到以下信息:

SQL 错误 [42883]:错误:函数 soundex(字符变化)不存在

我花了很多时间阅读 AWS / postgis / postgresql 论坛,但遗憾的是没有找到墙上的文字。

采取的步骤

安装了 POSTGIS 扩展

create EXTENSION postgis; 

安装了包含 soundex 函数的 FuzzyStrMatch 扩展(已验证)

create EXTENSION fuzzystrmatch; 

最后,当我运行这个创建扩展时,我得到了上面的错误

create extension postgis_tiger_geocoder;
SQL Error [42883]: ERROR: function soundex(character varying) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 57558
org.postgresql.util.PSQLException: ERROR: function soundex(character varying) does not exist
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Position: 57558

我尝试过的事情:

set search_path = <schema_name>, public

关注这里: Installing PostgreSQL Extension to all schemas 深入挖掘 postgis 安装文档 阅读有关添加扩展的 RDS 文档...

如果有人不得不在 AWS 上处理这种挫败感,我会很乐意交换我头上剩下的一些头发,因为我无法解决这个问题。

\dx+的结果

                      Objects in extension "fuzzystrmatch"
                               Object Description
--------------------------------------------------------------------------------
 function <schema>.difference(...)
 function <schema>.dmetaphone_alt(...)
 function <schema>.dmetaphone(...)
 function <schema>.levenshtein_less_equal(...)
 function <schema>.levenshtein_less_equal(...)
 function <schema>.levenshtein(...)
 function <schema>.levenshtein(...)
 function <schema>.metaphone(...)
 function <schema>.soundex(...)
 function <schema>.text_soundex(...)
(10 rows)

\dfS+ soundex 的结果

                                                                       List of functions
 Schema | Name | Result data type | Argument data types | Type | Volatility | Owner | Security | Access privileges | Language | Source code | Description
--------+------+------------------+---------------------+------+------------+-------+----------+-------------------+----------+-------------+-------------
(0 rows)

【问题讨论】:

  • \dx+\dfS+ soundex的结果粘贴到psql中
  • @Evan Carrol 更新
  • 好的,用\dx的结果更新
  • 你解决了这个问题吗?我在这里遇到了同样的问题,我头上没有更多的头发了......

标签: postgresql postgis amazon-rds


【解决方案1】:

遇到同样的问题,通过更改数据库的 search_path 并在创建扩展 postgis_tiger_geocoder 之前重新连接来解决它。寻找 FIX 部分:

-- Postgis Installation
------------------------------------------------------------------------------------------------------------------------------------------------
-- PostGIS AWS Configuration                                                                                                                  --
-- https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.PostgreSQL.CommonDBATasks.html#Appendix.PostgreSQL.CommonDBATasks.PostGIS  --
------------------------------------------------------------------------------------------------------------------------------------------------
-- On postgis schema
SET SCHEMA '${POSTGIS_SCHEMA_NAME}';
-- Step 2: Load the PostGIS Extensions
create extension postgis;
create extension fuzzystrmatch;
-- FIX : To avoid "ERROR:  function soundex(character varying) does not exist", change schema and reconnect
ALTER DATABASE ${DATABASE_NAME} SET search_path=${POSTGIS_SCHEMA_NAME};
\connect ${DATABASE_NAME};
-- End FIX
create extension postgis_tiger_geocoder;
create extension postgis_topology;
-- Step 3: Transfer Ownership of the Extensions to the rds_superuser Role
alter schema tiger owner to ${MASTER_USER};
alter schema tiger_data owner to ${MASTER_USER};
alter schema topology owner to ${MASTER_USER};
-- Step 4: Transfer Ownership of the Objects to the rds_superuser Role
CREATE FUNCTION exec(text) returns text language plpgsql volatile AS $f$ BEGIN EXECUTE $1; RETURN $1; END; $f$;
SELECT exec('ALTER TABLE ' || quote_ident(s.nspname) || '.' || quote_ident(s.relname) || ' OWNER TO ${MASTER_USER};')
  FROM (
    SELECT nspname, relname
    FROM pg_class c JOIN pg_namespace n ON (c.relnamespace = n.oid)
    WHERE nspname in ('tiger','topology') AND
    relkind IN ('r','S','v') ORDER BY relkind = 'S')
s;

-- Adding postgis to default schema
ALTER DATABASE ${DATABASE_NAME} SET search_path=${SCHEMA_NAME},${POSTGIS_SCHEMA_NAME};

【讨论】:

    【解决方案2】:

    遇到了同样的问题。事实证明,fuzzystrmatch 的所有函数都是在错误的模式中创建的。

    连接psql命令行,我使用drop extension命令重新启动创建扩展的过程:

    drop extension postgis_topology;
    drop extension postgis;
    drop extension fuzzystrmatch;
    

    然后,可以肯定的是,使用\q 断开连接。

    再次连接psql。

    将架构设置为公开:

    set schema 'public';
    

    然后,按照AWS RDS Docs中描述的流程进行

    create extension postgis;
    create extension fuzzystrmatch;
    create extension postgis_tiger_geocoder;
    create extension postgis_topology;
    

    【讨论】:

    • 感谢 Marco,这很有帮助。欣赏它。
    猜你喜欢
    • 2018-08-31
    • 2011-10-07
    • 2017-01-05
    • 2010-11-13
    • 2013-05-21
    • 1970-01-01
    • 1970-01-01
    • 2015-08-26
    • 1970-01-01
    相关资源
    最近更新 更多