AWS RDS PostgreSQL 9.5.4扩展postgis_tiger_geocoder缺少Soundex?

时间:2017-09-24 21:09:52

标签: postgresql postgis amazon-rds

我正在尝试安装AWS"已批准"我们在大型RDS实例上的PostgreSql扩展,但每次我尝试创建扩展名postgis_tiger_geocoder'我明白了:

  

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

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

采取的步骤

安装了POSTGIS扩展

create EXTENSION postgis; 

安装了FuzzyStrMatch Extension,其中包含soundex函数(已验证)

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)

2 个答案:

答案 0 :(得分:1)

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

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

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

然后,确定,使用\q断开连接。

再次连接psql。

将架构设置为public:

set schema 'public';

然后,按照AWS RDS Docs

中描述的过程进行操作
create extension postgis;
create extension fuzzystrmatch;
create extension postgis_tiger_geocoder;
create extension postgis_topology;

答案 1 :(得分:1)

遇到相同的问题,通过在创建扩展名postgis_tiger_geocoder之前更改数据库的search_path并重新连接来解决该问题。寻找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};