[postgis-devel] [PostGIS] #1814: the pgsql2shp tool should qualify its query against pg_class to ensure it gets the correct table to dump

PostGIS trac at osgeo.org
Mon May 14 09:21:40 PDT 2012


#1814: the pgsql2shp tool should qualify its query against pg_class to ensure it
gets the correct table to dump
---------------------+------------------------------------------------------
 Reporter:  chander  |       Owner:  pramsey      
     Type:  defect   |      Status:  new          
 Priority:  medium   |   Milestone:  PostGIS 2.0.1
Component:  postgis  |     Version:  2.0.x        
 Keywords:           |  
---------------------+------------------------------------------------------
 Currently, if two tables exist in two different schemas with the same name
 (i.e., a.shapefile_t and b.shapefile_t) the pgsql2shp command may obtain
 the wrong definition for the table being dumped, because it does not
 qualify its query properly against the pg_class (and related) tables.

 For example, it would run:
 SELECT a.attname, a.atttypid, a.atttypmod, a.attlen FROM pg_attribute a,
 pg_class c WHERE a.attrelid = c.oid and a.attnum > 0 AND a.atttypid != 0
 AND c.relname = 'shapefile_t'

 Where it should really run:
 SELECT a.attname, a.atttypid, a.atttypmod, a.attlen FROM pg_attribute a,
 pg_class c WHERE a.attrelid = c.oid and a.attnum > 0 AND a.atttypid != 0
 AND c.relname = 'shapefile_12354' and
 pg_catalog.pg_table_is_visible(c.oid);

 The additional " and pg_catalog.pg_table_is_visible(c.oid);" ensures that
 it only gets the schema for the columns that exist on the first visible
 table with the specified name in the currently defined search_path.

-- 
Ticket URL: <http://trac.osgeo.org/postgis/ticket/1814>
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-devel mailing list