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 |
Cc: |
Description
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 , 14 years ago
Component: | default → OGR_SF |
---|---|
Keywords: | postgres PG added |
Owner: | changed from | to
comment:2 by , 14 years ago
Status: | new → assigned |
---|
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 , 14 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
Chaitanya,
Could you look into a safe fix for this issue?