Opened 10 years ago

Closed 10 years ago

#5349 closed defect (fixed)

PostGIS delete layer failed

Reported by: bishop Owned by: warmerdam
Priority: normal Milestone:
Component: OGR_SF Version: svn-trunk
Severity: normal Keywords: PostGIS OGR DeleteLayer
Cc:

Description

In ogrpgdatasource.cpp the OGRPGDataSource::DeleteLayer provide such commands to PostGIS

BEGIN;
DELETE FROM geometry_columns WHERE f_table_name='roads' and f_table_schema='public';
DROP TABLE "public"."roads" CASCADE;
COMMIT;

But execution produce an error:

ERROR:  cannot delete from view "geometry_columns"
HINT:  You need an unconditional ON DELETE DO INSTEAD rule or an INSTEAD OF DELETE trigger.

********** Error **********

ERROR: cannot delete from view "geometry_columns"
You need an unconditional ON DELETE DO INSTEAD rule or an INSTEAD OF DELETE trigger.

As I see while deleting the PostGIS execute itself the trigger and "DELETE FROM geometry_columns WHERE f_table_name='roads' and f_table_schema='public';" not needed.

Version: PostgreSQL 9.1.9 on amd64-portbld-freebsd8.3, compiled by cc (GCC) 4.2.1 20070831 patched [FreeBSD], 64-bit

SELECT PostGIS_full_version();

"POSTGIS="2.0.0SVN" GEOS="3.3.1-CAPI-1.7.1" PROJ="Rel. 4.7.1, 23 September 2009" LIBXML="2.7.8" USE_STATS"

I think the some PG version check is needed in OGRPGDataSource::DeleteLayer. The sample check is in attached patch.

Attachments (1)

pg_dellayer.patch (568 bytes ) - added by bishop 10 years ago.

Download all attachments as: .zip

Change History (3)

by bishop, 10 years ago

Attachment: pg_dellayer.patch added

comment:1 by Even Rouault, 10 years ago

I don't reproduce any error message with PostgreSQL 9.1.2 and POSTGIS="2.0.1 r9979", but your patch is OK, so you can apply.

comment:2 by bishop, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r26817

Note: See TracTickets for help on using tickets.