Opened 16 years ago

Closed 15 years ago

#344 closed defect (fixed)

PostGIS Defect : selecting features does not work when primary index is not the first index ceated

Reported by: bscott Owned by:
Priority: blocker Milestone: 3.4.0
Component: PostGIS Provider Version: 3.2.0
Severity: 1 Keywords:
Cc: External ID:

Description

If the first index created on a PostGIS table is not the primary one, it's not possible to select a feature in Mapguide. To reproduce you just have to drop the primary index and recreate it, thus this index become created after the spatial index and selecting won't work anymore. To reanable it, just drop the spatial index and recreate it ... Another effect of this defect, is in mapguide studio when you created a new PostGIS data connection we have the ability to preview all the tables. All the unselectable tables are not displayed...

The bug reside in the PgTableColumnsReader class, the sql statement to retreive all the columns is incorrect

I have added a where condition on i.indisprimary = 't' and it fixed the problem.

"SELECT a.attnum AS ordinal_position, a.attname AS column_name" ",t.typname AS data_type, a.attlen AS character_maximum_length" ",a.atttypmod AS modifier, a.attnotnull AS notnull" ",a.atthasdef AS hasdefault, d.adsrc AS defaultVal" ",a.attnum = ANY (i.indkey) AS isprimarykey, i.indkey AS primKey, i.indisprimary AS indisprimary" " FROM pg_attribute a LEFT OUTER JOIN pg_attrdef d ON a.attrelid = d.adrelid" ", pg_type t, pg_namespace n" ", pg_class c LEFT OUTER JOIN pg_index i ON i.indrelid = c.oid" " WHERE a.attnum > 0 AND a.attrelid = c.oid" " AND a.atttypid = t.oid AND c.relnamespace = n.oid" " AND t.typname !~ 'geom'"

" AND i.indisprimary = 't'" " AND c.relname = '" + table + "' AND n.nspname = '" + schema + "' ORDER BY a.attnum;");

Attachments (1)

postgis_trunk_344.patch (633 bytes ) - added by bscott 16 years ago.
patch for ticket 344

Download all attachments as: .zip

Change History (5)

by bscott, 16 years ago

Attachment: postgis_trunk_344.patch added

patch for ticket 344

comment:1 by bscott, 15 years ago

Resolution: fixed
Status: newclosed

comment:2 by mloskot, 15 years ago

Resolution: fixed
Status: closedreopened

comment:3 by mloskot, 15 years ago

Owner: mloskot removed
Status: reopenednew

comment:4 by mloskot, 15 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.