Using CentOS 8.0 with PostgreSQL 12, PostGIS 3, and GDAL/OGR 3.0.1. I want to append a file to a database table.
Previously (before upgrading to the new system) I used
ogr2ogr -f "PostgreSQL" PG:"dbname=dev user=admin password=123 host=0.0.0.0 port=5432" -lco "SCHEMA=myschema" -lco "GEOMETRY_NAME=geog" -append -sql "select ID as gid from input" input.gen
However, that fails now with
ERROR 1: ERROR: column s.consrc does not exist LINE 1: ...nrelid = c.oid AND a.attnum = ANY (s.conkey) AND (s.consrc L... ^
HINT: Perhaps you meant to reference the column "s.conkey" or the column "s.c onbin".
ERROR 1: ERROR: column s.consrc does not exist LINE 1: ...nrelid = c.oid AND a.attnum = ANY (s.conkey) AND (s.consrc L... ^
HINT: Perhaps you meant to reference the column "s.conkey" or the column "s.c onbin".
ERROR 1: Layer myschema.input already exists, CreateLayer failed. Use the layer creation option OVERWRITE=YES to replace it.
ERROR 1: Terminating translation prematurely after failed translation from sql statement.
If I make a PGDUMP with
ogr2ogr -f "PGDUMP" -lco "SCHEMA=myschema" -lco "GEOMETRY_NAME=geog" -append -sql "select ID as gid from input" test.dump input.gen
I can run that file in psql
and import the data, but I would like to avoid that extra step of writing a large pgdump file.
Notes
- It also fails without
-append
- It fails with other input data types and files as well (Shapefile, ArcGEN, and GeoJSON)
- Columns mentioned in the Error message are not part of my input data.
- I suspect that it has something to do with PostgreSQL 12 dropping OID
2 Answers 2
I have the same issue (this morning) and started to search for some solutions and the only thing I found is that is a GDAL PG12 problem, which was solved in a commit of GDAL in July 2019.
This means we have to fix this manually or upgrade our GDAL. Your GDAL version is from June 2019, mine also.
-
Depends of OS, if app/python etc.mazinga– mazinga2020年04月10日 07:16:45 +00:00Commented Apr 10, 2020 at 7:16
-
1Do you know any PPA wich includes this fix in GDAL for Ubuntu 18.04?swiss_knight– swiss_knight2020年05月08日 14:22:08 +00:00Commented May 8, 2020 at 14:22
-
1Is there a way to get this bug fix in Debian 10 Buster?thibautg– thibautg2020年05月23日 18:43:14 +00:00Commented May 23, 2020 at 18:43
Can confirm that 3.0.1 has the bug, but it is solved in 3.0.2 as mentioned correctly in the comments here by @michael. The version number is important to mention here.