[postgis-tickets] [PostGIS] #2485: SQL functions namespace qualification

PostGIS trac at osgeo.org
Mon Sep 23 05:54:40 PDT 2013


#2485: SQL functions namespace qualification
----------------------+-----------------------------------------------------
 Reporter:  rdunklau  |       Owner:  pramsey
     Type:  defect    |      Status:  new    
 Priority:  medium    |   Milestone:         
Component:  postgis   |     Version:  2.0.x  
 Keywords:            |  
----------------------+-----------------------------------------------------
 The sql functions installed by PostGIS should probably set their own
 search path, or qualify the underlying function calls namespace.

 Take the following function definition from raster/rt_pg/rtpostgis.sql.in:


 {{{

     CREATE OR REPLACE FUNCTION _raster_constraint_pixel_types(rast raster)
         RETURNS text[] AS
         $$ SELECT array_agg(pixeltype)::text[] FROM st_bandmetadata($1,
 ARRAY[]::int[]); $$
         LANGUAGE 'sql' STABLE STRICT;

 }}}

 The call to st_bandmetadata is not qualified. Therefore, when using this
 function in a constraint definition in another schema than public (let's
 say ns1), the table data can not be dumped and restored, since pg_restore
 sets the search_path to ns1, pg_catalog. This skips entirely the schema in
 which the st_bandmetadata resides (public, by default).

 This has another implication: this means that those function calls should
 probably be qualified by the @extschema@ namespace, which makes the
 extension non-relocatable.

 Please find attached a simple test case.

 How to reproduce:

 - create a database
 - run the supplied script against this database
 - use pg_dump to create a dump of the given database
 - use pg_restore to restore this dump

 What is expected:

 - the dump is restored successfully

 What happens:

 - the data from the ns1.t1 table is not restored, due to search_path
 issues when calling the check constraint function.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/2485>
PostGIS <http://trac.osgeo.org/postgis/>
The PostGIS Trac is used for bug, enhancement & task tracking, a user and developer wiki, and a view into the subversion code repository of PostGIS project.


More information about the postgis-tickets mailing list