我安装了一个 Postgres 扩展 (unaccent)。
sudo su posgres
psql create extension unaccent
现在我可以在SQL中使用unaccent,但前提是我必须作为Postgres用户进行操作。
如何将Postgres扩展程序对所有用户/另一个用户开放?
(我正在使用Ubuntu,使用apt-install安装了Postgres 9.3.5)
jthinksearch=# \dx;
List of installed extensions
Name | Version | Schema | Description
----------+---------+------------+---------------------------------------------
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
unaccent | 1.0 | public | text search dictionary that removes accents
(2 rows)
jthinksearch=#
jthinksearch=> \du;
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
ubuntu | | {}
postgres@ip-172-31-39-147:/home/ubuntu/code/jthinksearch/reports/src/main/sql$ exit ubuntu@ip-172-31-39-147:~/code/jthinksearch/reports/src/main/sql$ psql jthinksearch psql (9.3.5) Type "help" for help.
我给了用户超级用户角色,但这没有帮助,然后按建议在中放置模式名称,这对错误消息产生了影响,但仍未起作用。
jthinksearch=# \du;
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------+-----------
postgres | Superuser, Create role, Create DB, Replication | {}
ubuntu | Superuser | {}
jthinksearch=# select unaccent(name) from musicbrainz.artist where id=195660;
ERROR: function unaccent(character varying) does not exist
LINE 1: select unaccent(name) from musicbrainz.artist where id=19566...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
jthinksearch=# ^C
jthinksearch=# select public.unaccent(name) from musicbrainz.artist where id=195660;
ERROR: text search dictionary "unaccent" does not exist
jthinksearch=#
select public.unaccent('foo')
命令,并分享您遇到的错误。 - Daniel Vérité