问题
When creating a new user on our Potgis enabled database I run into the strange issue that that new user cannot access the postgis extension while earlier created users can.
With my user account I get the following output:
mydb => SELECT postgis_version();
postgis_version
---------------------------------------
2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1
(1 row)
With the new user I get the following:
mydb => SELECT postgis_version()
mydb-> ;
ERROR: function postgis_version() does not exist
LINE 1: SELECT postgis_version()
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
Also QGIS is giving me hint that postgis is not active:
2018-01-23T16:38:13 1 No PostGIS support in the database.
I am connecting to the exact same database. The user does have access to the public schema and to the geometry_columns table.
I am a bit lost here since according to my info Postgis is an extansion on the database level and it should be there for all users.
回答1:
The PostGIS extension must be installed in a schema that must also be in the user search path.
You can check where it is installed with the command
select e.extname,n.*
from pg_extension e, pg_namespace n
where e.extnamespace = n.oid and e.extname='postgis';
And you can check if the schema where it is installed is in the user search path by issuing
show search_path;
If not, you can permanently add the path by altering the user.
ALTER USER username SET search_path TO "$user", public, postgis_schema;
As the previous command takes effect at the next login only, you can apply it immediately by applying
SET search_path TO "$user", public, postgis_schema;
来源:https://stackoverflow.com/questions/48407622/postgis-not-available-for-all-postgres-users