#3490 closed defect (fixed)
Create perl script to add in the ALTER FUNCTION set path calls
Reported by: | robe | Owned by: | robe |
---|---|---|---|
Priority: | blocker | Milestone: | PostGIS 2.2.2 |
Component: | postgis | Version: | 2.2.x |
Keywords: | restore, materialized views, foreign tables, raster | Cc: |
Description (last modified by )
As discussed in several tickets.
PostGIS functions that call postgis functions fail when the schema that postgis is installed in is not in the search_path.
The generated script will look something like this - https://trac.osgeo.org/postgis/browser/trunk/postgis/postgis_functions_search_path.sql for will have all functions
Such a scenario happens in the following cases:
- During database restore - raster constraints rely on functions that call other functions, and as a result data does not come back if your data is not in the same schema as where postgis is installed
- Restore of spatial indexes that use ST_Transform, again if your data is not in same schema as postgis.
- Materialized views restore - views that use ST_Intersects etc. may not come back. So this is fairly serious. Again if not in same schema as postgis
- Foreign Tables. The Foreign tables as I recall are set to ignore search_path so a foregin table calling ST_Intersects etc will fail if the table is not in the same schema as where PostGIS is installed.
I'm working on a perl script to set the search_path setting of all functions. I plan to distribute this as part of PostGIS 2.2 (not as part of extension install). With an FAQ in the docs that people suffering from this issue need to
1) Install postgis first
2) Run this script
3) then restore their data
For PostGIS 2.3, I'd like to just include this as part of the CREATE EXTENSION install so I don't have to explain this to anybody ever again.
At least 5 people have complained to me about this already and I have suffered from it myself. Enough is enough.
Change History (11)
comment:1 by , 9 years ago
Owner: | changed from | to
---|
comment:3 by , 9 years ago
Okay this is a bit of a bummer. Looks like setting the search_path of function thwarts the use of spatial indexes. So I guess I can't blindly set it on all functions as I had hoped.
The issue seems to be that setting the search_path makes the SQL functions not inlined anymore. So guess it can't be used on any of the relationship functions which is a bummer since that's a lot of the area we have issue.
comment:4 by , 9 years ago
comment:5 by , 9 years ago
Description: | modified (diff) |
---|
comment:6 by , 9 years ago
comment:7 by , 9 years ago
Keywords: | restore materialized views foreign tables raster added |
---|
Okay I think I have an 80% winner here. I revised the script to not put in search path on SQL functions that are not marked as STRICT.
C, plpgsql, and STRICT sql functions can't be inlined, so for those it's fine that search_path makes inlining not possible.
This should fix partly:
#3076 (it will handle ST_Distance for example, however it will not handle ST_DWithin in postgres fdw and materialized views.
#3012 - this will fix since ST_AsLatLonText will now have a function search path.
#3277 - this will be fixed too since non of the constraint functions are non strict and are for the most part plpgsql
#3485 - will also be fixed
comment:8 by , 9 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
<del>This is a little annoying. I have the script all ready and put it as part of create extension. It doesn't error but also doesn't set search path of the functions. I checked and the script has it. Anyway going to check in my 2.3 work in a bit and back port the perl script and make file changes to generate the script for postgis and raster.</del>
Was mistaken - got the wrong postgres instance running.