Opened 13 years ago

Closed 13 years ago

#1814 closed defect (fixed)

the pgsql2shp tool should qualify its query against pg_class to ensure it gets the correct table to dump

Reported by: chander Owned by: pramsey
Priority: medium Milestone: PostGIS 2.0.1
Component: postgis Version: 2.0.x
Keywords: Cc:

Description

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.

Change History (2)

comment:1 by chander, 13 years ago

In retrospect, this should really only be the case when the user doesn't fully qualify the name of the table they are attempting to dump (i.e., don't specify an exact schema)

comment:2 by pramsey, 13 years ago

Resolution: fixed
Status: newclosed

Committed to trunk at r9758

Note: See TracTickets for help on using tickets.