Opened 9 years ago
Last modified 9 years ago
#3496 closed defect
Make postgis non-relocateable and schema qualify at least core functions — at Initial Version
Reported by: | robe | Owned by: | pramsey |
---|---|---|---|
Priority: | high | Milestone: | PostGIS 2.3.0 |
Component: | build | Version: | master |
Keywords: | history | Cc: |
Description
I misunderstood the docs a bit. I blame pgAdmin for my stupidity because it always greyed out the schema feature in extension gui if an extension is marked non-relocatable.
I did some experiments, and it does seem that we can schema qualify our functions, without forcing users to install postgis in postgis schema. Though I still think that is where we want to move for the sake of other extensions that may rely on postgis.
Sooo if we have our control file look like this:
# postgis extension comment = 'PostGIS geometry, geography, and raster spatial types and functions' default_version = '2.3.0dev' module_pathname = '$libdir/postgis-2.3' relocatable = false
Then we can use the variable @extschema@ in lieu of the actual schema name. This will still allow users to do:
CREATE EXTENSION postgis SCHEMA whereever_I_damn_want_you_to_be;
And if I then have ST_Intersects rewritten as:
CREATE OR REPLACE FUNCTION ST_Intersects(geom1 geometry, geom2 geometry) RETURNS boolean AS 'SELECT $1 && $2 AND @extschema@._ST_Intersects($1,$2)' LANGUAGE 'sql' IMMUTABLE;
Once installed, in the desired user location, it will then become:
CREATE OR REPLACE FUNCTION ST_Intersects(geom1 geometry, geom2 geometry) RETURNS boolean AS 'SELECT $1 && $2 AND whereever_I_damn_want_you_to_be._ST_Intersects($1,$2)' LANGUAGE 'sql' IMMUTABLE;
upon installation. The downside being, the user can't then do:
ALTER EXTENSION postgis SET schema public;
They'll get a
ERROR: extension "postgis" does not support SET SCHEMA
Now how to make this work nicely with non-extension piece.
I suppose when we are creating the scripts for regular old postgis install.