OSGeo / gdal

GDAL is an open source MIT licensed translator library for raster and vector geospatial data formats.
https://gdal.org
Other
4.91k stars 2.55k forks source link

Empty or raster-only FileGeodatabase can be opened by the OpenFileGDB driver / ogr2ogr doesn't error on empty source dataset #1663

Open ethervoid opened 5 years ago

ethervoid commented 5 years ago

Expected behavior and actual behavior.

I expected the file to be processed and imported in my PostgreSQL table but is does nothing instead (even return an error)

Steps to reproduce the problem.

ogr2ogr -f PostgreSQL PG:'host=127.0.0.1 port=5432 user=testuser dbname=test' -t_srs EPSG:4326 -lco DIM=2 -lco PRECISION=NO file.gdb -nln testtable -nlt PROMOTE_TO_MULTI -doo PRELUDE_STATEMENTS="SET statement_timeout TO '1h'" -doo CLOSING_STATEMENTS="SET statement_timeout TO DEFAULT" -update --config CPL_DEBUG OpenFileGDB

I've tried to debug it myself but I run out of time. You can see here the output:

Reading symbols from ./apps/.libs/ogr2ogr...
(gdb) run
Starting program: /home/vagrant/repos/repos/gdal/gdal/apps/.libs/ogr2ogr -f PostgreSQL PG:host=127.0.0.1\ port=5432\ user=testuser\ dbname=test -t_srs EPSG:4326 -lco DIM=2 -lco PRECISION=NO /home/vagrant/repos/cartodb/tmp/nasjonal-ramme-gis/nrvf_myke_eksklusjoner.gdb -nln testtable -nlt PROMOTE_TO_MULTI -doo PRELUDE_STATEMENTS=SET\ statement_timeout\ TO\ \'1h\' -doo CLOSING_STATEMENTS=SET\ statement_timeout\ TO\ DEFAULT -update --config CPL_DEBUG OpenFileGDB
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
OpenFileGDB: FileGDB v10 or later
OpenFileGDB: File name 0�jUUU
[Inferior 1 (process 1350) exited normally]
(gdb) q
vagrant@test-dev-box:~/repos/repos/gdal/gdal$ psql -U testuser -d test
psql (11.3 (Ubuntu 11.3-0ubuntu0.19.04.1))
Type "help" for help.

test=> \d
Did not find any relations.
test=> \q

Operating system

Ubuntu 19.04 64 bit

File to reproduce the problem

You have it here

GDAL version and provenance

GDAL 2.2.2, released 2017/09/15 GDAL 2.5.0beta1, released 2019/04/19

rouault commented 5 years ago

This filegeodatabase only contains raster layers, which are ignored both by the FileGDB and OpenFileGDB drivers. The dataset can however been opened, but it reports 0 vector layer. In a similar situation, if we have a GeoPackage with raster content only (or empty), and try to open it in read-only mode, the GPKG driver refuses to open it. But for an empty PostgreSQL database, we would happifly return a 0 layer dataset. So we aren't really consistent among drivers

rcoup commented 5 years ago

IMO a warning from ogr2ogr & not erroring is a sane default behaviour; but consistency is the more important aspect.

ethervoid commented 5 years ago

Great, thank you for explaining the cause. Hope it helps to improve it :)