pramsey / pgsql-ogr-fdw

PostgreSQL foreign data wrapper for OGR
MIT License
237 stars 34 forks source link

Segfault on pg_relation_is_updatable #179

Closed nextstopsun closed 3 years ago

nextstopsun commented 4 years ago

PostgreSQL terminates with Segmentation fault when running pg_relation_is_updatable function on a foreign table.

Try this:

SELECT
  pg_relation_is_updatable(c.oid::regclass, FALSE)
FROM
  pg_class c,
  pg_namespace n
WHERE
  n.oid = c.relnamespace
  AND c.relname = 'fdw_schema'
  AND n.nspname = 'fdw_table';

In my case, a table source is a vrt file with an MSSQL datasource.

dmesg reports this: segfault at 0 ip 00007f863cd5b547 sp 00007ffe174b1a30 error 4 in libgdal.so.20.5.0

running GDAL 2.4.0, ogr_fdw 1.0.8 on PostgreSQL 12.1

Setting false on both foreign server and foreign table updateable option doesn't heal it.

pramsey commented 4 years ago

I loaded the test pt_two.shp as a table per the README example, and I'm not seeing the crash against master.

SELECT pg_relation_is_updatable(c.oid::regclass, FALSE)
FROM pg_class c, pg_namespace n
WHERE  n.oid = c.relnamespace
AND c.relname = 'pt_two' AND n.nspname = 'public';
 pg_relation_is_updatable 
--------------------------
                       28
(1 row)
robe2 commented 4 years ago

FWIW I have a ODBC pointing at MSSQL and also MSSpatial. Neither of them segfaults. Using ogrfdw 1.0.9 , GDAL 2.4.4

PostgreSQL 12.3, compiled by Visual C++ build 1914, 64-bit

For the ODBC variant I get

 pg_relation_is_updatable 
--------------------------
                      0

For the MSSPatial I get

pg_relation_is_updatable 
--------------------------
                       28
(1 row)

I've never tried using a vrt file source and not quite sure how to set that up.

Have you tried direct SQL Server link using ODBC or the MSSpatial driver?

robe2 commented 4 years ago

@nextstopsun Can you provide details as to what OS you are running and if you got your stuff from packages and also the contents of your vrt file.

@pramsey and I can not replicate the issue so I'm guessing it's either some faulty compile or something to do with VRTs and may be only triggerable with a VRT source.