pramsey/pgsql-ogr-fdw

ogr_fdw_info returns different configuration than ogr_all

Closed this issue · 4 comments

When using ogr_fdw_info with:
ogr_fdw_info -s ODBC:foo@bar -l foo.acp_stuff

it returns

CREATE FOREIGN TABLE acp_stuff(
fid bigint,
geom Geometry(Geometry),
acp_no varchar(10),
.
.
.

This will fail however since there is no column called 'Geometry'. I have been commenting this out by hand. However, When I do:

CREATE SCHEMA testall;

IMPORT FOREIGN SCHEMA ogr_all
FROM SERVER foo_test
INTO testall;

The same table is created as:

CREATE FOREIGN TABLE testall.acp_stuff(
fid bigint NULL,
geom geometry NULL,
acp_no character varying(10) NULL COLLATE pg_catalog."default",
.
.
.

This works fine with no errors because the fields fid and geometry are not found. The values for fid are added later but the geom field stays NULL.

(Great option ogr_all BTW)

Can I have a duplication case using ogr_fdw_info and something easy like a csv file or a dbf file? I really don't get what you're saying, the two tables look the same to me.

Looks like it doesn't happen in a csv file. Let me keep looking.

My suspicion is that ODBC driver advertises a geometry column every time, even when it doesn't have one. If the driver says it has one, FDW can't do anything except believe it.

The issue was that ogr_info_fdw is generating the line:
geom Geometry(Geometry),
while ogr_all generated:
geom geometry NULL,

The first version used to throw an error since there is no 'Geometry' field while the second worked fine. However, I can no longer recreate the error so something recent has fixed this.