Opened 14 years ago

Closed 14 years ago

#3480 closed defect (fixed)

ogr2ogr -overwrite does not work if target is PostGIS table which name begins with "pg"

Reported by: niccolo Owned by: chaitanya
Priority: normal Milestone:
Component: OGR_SF Version: unspecified
Severity: normal Keywords: postgres PG


Running ogr2ogr with option -overwrite and destination a PostGIS table which name begins with "pg": it does not execute the DROP TABLE statement, causing a subsequent PostgreSQL error:

ERROR:  relation "pgip_zone_2008" already exists

The problem is in ogr/ogrsf_frmts/pg/ogrpgdatasource.cpp: when searching for tables it imposes:

c.relname !~ '^pg'

I suppose it is to to skip PostgreSQL system tables, but this skips also user tables.

A slightly better approach is to skip "^pg_" prefix, but I suppose it can be even better.

Change History (3)

comment:1 by warmerdam, 14 years ago

Component: defaultOGR_SF
Keywords: postgres PG added
Owner: changed from warmerdam to chaitanya


Could you look into a safe fix for this issue?

comment:2 by chaitanya, 14 years ago

Status: newassigned

According to the PostgreSQL documentation, it should be enough to avoid the pg_ prefix for table and schema names. This is the easiest method and is supposed to be future proof.

I'm applying niccolo's suggestion.

comment:3 by chaitanya, 14 years ago

Resolution: fixed
Status: assignedclosed

Fixed in trunk (r19141), 1.7 branch (r19142) and the 1.6 branch (r19143).

Note: See TracTickets for help on using tickets.