Opened 13 years ago

Closed 13 years ago

#4217 closed defect (fixed)

OGRDataSource::CreateLayer() fails for PostGIS 2.0

Reported by: martinl Owned by: warmerdam
Priority: highest Milestone: 1.9.0
Component: OGR_SF Version: svn-trunk
Severity: critical Keywords: postgis, create layer, geometry_columns
Cc: pramsey

Description

Since PostGIS 2.0 defines geometry_columns as a view, OGRDataSource::CreateLayer() fails when executing

osCommand.Printf(
	     "DELETE FROM geometry_columns WHERE f_table_name = %s AND f_table_schema = '%s'",
	     pszEscapedTableNameSingleQuote, pszSchemaName )

The attached patch checks whether geometry_columns is a table or a view.

Attachments (1)

postgis2.diff (1.6 KB ) - added by martinl 13 years ago.

Download all attachments as: .zip

Change History (2)

by martinl, 13 years ago

Attachment: postgis2.diff added

comment:1 by Even Rouault, 13 years ago

Cc: pramsey added
Resolution: fixed
Status: newclosed

I've fixed a bit differently by testing the postgis major version that we fetch at datasource creation. This saves up a query.

r23012 /trunk/gdal/ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp: PG: add compat for latest Postgis 2.0SVN where geometry_columns is now a view (fix table creation, #4217)

Note: See TracTickets for help on using tickets.