码迷,mamicode.com
首页 > 其他好文 > 详细

ERROR: extension “postgis” does not support SET SCHEMA.

时间:2020-06-01 12:14:38      阅读:82      评论:0      收藏:0      [点我收藏+]

标签:rest   include   fixed   issue   postgis   admin   sch   ble   gad   

参考:  http://postgis.net/2017/11/07/tip-move-postgis-schema/

Move PostGIS extension to a different schema


As of PostGIS 2.3, the postgis extension was changed to no longer allow relocation. All function calls within the extension are now schema qualified.

While this change fixed some issues with database restore, it created the issue of if you installed PostGIS in a schema other than the one you wanted to it is not intuitive how to move it to a different schema. Luckily there is a way to do this.

For this exercise, I will install PostGIS in the default schema and then demonstrate how to move it into another schema location.

You can run these steps using psql or pgAdmin or any other PostgreSQL tool you want.

Most people have their default schema set to public so not explicitly specifying an install schema will generally install postgis in the public schema.

CREATE EXTENSION postgis;

Now I’ll create a new schema to move it and add this schema to search_path

CREATE SCHEMA postgis;
 
ALTER DATABASE mydb 
SET `search_path` = public,postgis;
If you are running PostGIS 2.3 or higher, trying to move to a different schema using the usual step:
ALTER EXTENSION postgis 
  SET SCHEMA postgis;

will fail with error ERROR: extension “postgis” does not support SET SCHEMA.

To allow the move do these steps:

UPDATE pg_extension 
  SET extrelocatable = TRUE 
    WHERE extname = postgis;
 
ALTER EXTENSION postgis 
  SET SCHEMA postgis;
 
ALTER EXTENSION postgis 
  UPDATE TO "2.4.1next";
 
ALTER EXTENSION postgis 
  UPDATE TO "2.4.1";
Note the use of the extension version that includes next. The next version step is needed in order to upgrade all the schema qualified function references to the new schema location. next is designed to allow upgrading a postgis extension to a version it is already on. Trying to run UPDATE TO “2.4.1” when you are already on 2.4.1 would trigger an error that you are already on that version.

ERROR: extension “postgis” does not support SET SCHEMA.

标签:rest   include   fixed   issue   postgis   admin   sch   ble   gad   

原文地址:https://www.cnblogs.com/gispathfinder/p/13024194.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!