首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >错误:在匹配postgis自定义模式时,函数postgis_lib_version()不存在

错误:在匹配postgis自定义模式时,函数postgis_lib_version()不存在
EN

Stack Overflow用户
提问于 2020-07-28 18:03:14
回答 1查看 3.4K关注 0票数 2

我有一个带有PostGIS数据库的rails应用程序,它运行在码头容器中。我使用多租户公寓activerecord postgis-适配器从ActiveRecord访问PostGIS地理空间数据库特性。正如公寓文档所建议的那样,我已经在shared_extentions模式中安装了shared_extentions。当我试图在geoserver中配置数据存储时,我会得到以下错误:

代码语言:javascript
运行
复制
Error creating data store, check the parameters. Error message: Unable to obtain connection: ERROR: function postgis_lib_version() does not exist Hint: No function matches the given name and argument types. You might need to add explicit type casts. Position: 8

Geoserver数据存储连接参数:

代码语言:javascript
运行
复制
host: app-db
port: 5432
database: app_development
schema: shared_extensions
user: 
passwd:

database.yml

代码语言:javascript
运行
复制
default: &default
  adapter: postgis
  postgis_schema: shared_extensions
  schema_search_path: public, shared_extensions
  encoding: unicode
  database: app_development
  host: app-db
  username:
  password:

lib/tasks/db_enhancements.rake

代码语言:javascript
运行
复制
namespace :db do
  desc 'Also create shared_extensions Schema'
  task :extensions => :environment  do
    # Create Schema
    ActiveRecord::Base.connection.execute 'CREATE SCHEMA IF NOT EXISTS shared_extensions;'
    # Enable Hstore
    ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS HSTORE SCHEMA shared_extensions;'
    # Enable Postgis
    ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS postgis SCHEMA shared_extensions;'
    # Enable UUID-OSSP
    ActiveRecord::Base.connection.execute 'CREATE EXTENSION IF NOT EXISTS "uuid-ossp" SCHEMA shared_extensions;'
    # Grant usage to public
    ActiveRecord::Base.connection.execute 'GRANT usage ON SCHEMA shared_extensions to public;'
  end
end

我还在pgAdmin上用SELECT shared_extensions.postgis_version()试用了它,它运行得很好:

代码语言:javascript
运行
复制
2.3 USE_GEOS=1 USE_PROJ=1 USE_STATS=1

但是,当然,当我运行SELECT postgis_version()时,我得到:

代码语言:javascript
运行
复制
ERROR:  function postgis_version() does not exist
LÍNEA 1: SELECT postgis_version()
                ^
SUGERENCIA:  No function matches the given name and argument types. You might need to add explicit type casts.
SQL state: 42883
Hint: No function matches the given name and argument types. You might need to add explicit type casts.
Character: 8
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-30 12:37:35

GeoServer希望PostGIS安装在公共模式中,不会将shared_extensions放在其postgis函数的前面。如果您想要这样做,那么您需要将shared_extensions添加到搜索路径中,以便GeoServer能够找到它需要的函数。

代码语言:javascript
运行
复制
ALTER DATABASE mydb SET 'search_path' = public,shared_extension;

有关如何将postgis移动到不同架构的详细信息,请参阅此备注

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63140216

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档