Ticket #344 (closed defect: fixed)

Opened 4 years ago

Last modified 3 years ago

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

postgis_trunk_344.patch Download (0.6 KB) - added by bscott 4 years ago.
patch for ticket 344

Change History

Changed 4 years ago by bscott

patch for ticket 344

Changed 3 years ago by bscott

  • status changed from new to closed
  • resolution set to fixed

Changed 3 years ago by mloskot

  • status changed from closed to reopened
  • resolution fixed deleted

Changed 3 years ago by mloskot

  • owner mloskot deleted
  • status changed from reopened to new

Changed 3 years ago by mloskot

  • status changed from new to closed
  • resolution set to fixed
Note: See TracTickets for help on using tickets.