<div dir="ltr"><div>Hi Regina, Paul & List</div><div><br></div><div>Thanks so much for your suggestions - they have directed me to the cause and solution.</div><div><br></div><div>The cause was two tables of ~PostGIS 8.4 vintage with geometry columns of unknown SRID which were allocated a SRID of -1 back in those days. With PostGIS 2.0 unknown SRIDs were changed from -1 to 0 (<a href="http://postgis.net/docs/release_notes.html#idp82265344">http://postgis.net/docs/release_notes.html#idp82265344</a>). This did not manifest itself as a problem with earlier versions of PostGIS (at least up to 2.1.7), but does with 2.2.0, when...</div><div><br></div><div>select * from geometry_columns</div><div><br></div><div>will output the "invalid input syntax for integer: "'-1'::integer"" error.</div><div><br></div><div>The solution I chose was to pg_dump the schema in sql format from Postgres 9.4/Postgis 2.1.7 and edit the constraints in this file to reflect the unknown SRID change.</div><div><br></div><div>from </div><div><br></div><div> CONSTRAINT enforce_srid_wkb_geometry CHECK ((public.st_srid(wkb_geometry) = (-1)))</div><div> </div><div> to </div><div> </div><div>  CONSTRAINT enforce_srid_wkb_geometry CHECK ((public.st_srid(wkb_geometry) = (0)))</div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre">then restoring to PostGIS 2.2.0 (a</span>lthough I suppose updating the SRIDs in the source database before dumping would work too).</div><div><br></div><div>Thanks again</div><div><br></div><div>Chris<span class="" style="white-space:pre">   </span></div><div><span class="" style="white-space:pre">   </span></div><div class="gmail_extra"><br><div class="gmail_quote">On 27 October 2015 at 21:48, Paragon Corporation <span dir="ltr"><<a href="mailto:lr@pcorp.us" target="_blank">lr@pcorp.us</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Chris,<br>
<br>
This could be a data specific problem like possible a view or something gdal or geometry_columns is tripping on.<br>
1) Can you do:<br>
<br>
SELECT * FROM geometry_columns;<br>
<br>
Okay<br>
<br>
<br>
2) Do you have the same set of data in your PostgreSQL 9.5beta1 as you do in PostgreSQL 9.4?<br>
<br>
To test I did this on a windows 2012 R2 64-bit database server<br>
PostgreSQL 9.5beta1, compiled by Visual C++ build 1800, 64-bit<br>
POSTGIS="2.2.0 r14208" GEOS="3.5.0-CAPI-1.9.0 r4090" SFCGAL="1.2.0" PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.1, released 2015/09/15" LIBXML="2.7.8" LIBJSON="0.12" TOPOLOGY RASTER<br>
<br>
And queried from my desktop where I have an old dev gdal:<br>
<br>
GDAL 1.12dev, released 2014/04/16<br>
<br>
ogrinfo -q PG:"dbname=pgr host=y user=postgres password=whatever port=5440"<br>
<br>
<br>
1: airports (Point)<br>
2: routes (Line String)<br>
3: routes_vertices_pgr (Point)<br>
4: ospr.ways_vertices_pgr (Point)<br>
5: ospr.ways (Line String)<br>
6: ospr.osm_nodes (Point)<br>
7: ospr.vw_sample (Line String)<br>
8: tiger.county (Multi Polygon)<br>
9: tiger.state (Multi Polygon)<br>
10: tiger.place (Multi Polygon)<br>
11: tiger.cousub (Multi Polygon)<br>
12: tiger.edges (Multi Line String)<br>
13: tiger.addrfeat (Line String)<br>
14: tiger.faces (Multi Polygon)<br>
15: tiger.zcta5 (Multi Polygon)<br>
16: tiger.tract (Multi Polygon)<br>
17: tiger.tabblock (Multi Polygon)<br>
18: <a href="http://tiger.bg" rel="noreferrer" target="_blank">tiger.bg</a> (Multi Polygon)<br>
<br>
<br>
Also I tried pramsey's query on my PostgreSQL 9.5beta1 instance:<br>
select '-1'::integer;<br>
<br>
and it works just fine.<br>
<br>
I even tried with an unprivileged account that just has read access to a couple of tables:<br>
ogrinfo -q PG:"dbname=pgr host=y user=test password=test port=5440"<br>
<br>
and got:<br>
<br>
1: airports (Point)<br>
2: routes (Line String)<br>
3: routes_vertices_pgr (Point)<br>
<br>
<br>
I also tried with a brand new db with just postgis and it doesn't error out, just gives no result as expected.<br>
<br>
<br>
<br>
<br>
So at a glance there is nothing wrong (unless it is specific to GDAL 1.11).<br>
<br>
It is also possible maybe the GDAL 2.0 settings (especially if you said YES to override system env variables during PostGIS 2.2 install) are overriding your GDAL 1.11 in some horrible way (though I can't think of a setting that would cause an issue like this).<br>
<br>
I've run into issues only with OSM data that GDAL 2.0 default config throws in an extra column that GDAL 1.11 doesn't emit and that causes issues if say you have a discrepancy .<br>
<br>
Thanks,<br>
Regina<br>
<br>
<br>
-----Original Message-----<br>
From: postgis-users [mailto:<a href="mailto:postgis-users-bounces@lists.osgeo.org">postgis-users-bounces@lists.osgeo.org</a>] On Behalf Of Paul Ramsey<br>
Sent: Tuesday, October 27, 2015 8:45 AM<br>
To: PostGIS Users Discussion <<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a>><br>
Subject: Re: [postgis-users] PostgreSQL 9.5 beta/PostGIS 2.2.0 fails with OGR<br>
<br>
I'm unable to reproduce any of this, though admittedly I'm not on a<br>
9.5 install, but on a "9.6" (aka git master) install.<br>
<br>
pramsey=# select '-1'::integer;<br>
<br>
 int4<br>
<br>
------<br>
<br>
   -1<br>
<br>
(1 row)<br>
<br>
Crane:~/Sites/crackedtiles/pgsample pramsey(master)$ ogrinfo -q PG:"dbname=gis"<br>
<br>
1: continent (Multi Polygon)<br>
<br>
So, keep on investigating...<br>
<br>
P<br>
<br>
On Tue, Oct 27, 2015 at 2:49 AM, Chris Hill <<a href="mailto:chill@confusedsea.co.uk">chill@confusedsea.co.uk</a>> wrote:<br>
> Hi folks,<br>
><br>
> I'm exploring Postgres 9.5 beta with PostGIS 2.20 (full versions<br>
> listed<br>
> below) on Windows 7 64 bit. All works as expected except for OGR which<br>
> fails when attempting to access a PostGIS enabled database (but works<br>
> for non-PostGIS databases).<br>
><br>
> This command succeeds with Postgres 9.4 and PostGIS 2.1.7:<br>
><br>
> C:\>ogrinfo -q PG:"dbname=postgis user=postgres port=5436"<br>
><br>
> Whereas this fails on a new installation of Postgres 9.5 and PostGIS 2.2.0:<br>
><br>
> C:\>ogrinfo -q PG:"dbname=postgis user=postgres port=5437"<br>
> ERROR 1: ERROR:  invalid input syntax for integer: "'-1'::integer"<br>
><br>
> ERROR 1: ERROR:  invalid input syntax for integer: "'-1'::integer"<br>
><br>
> FAILURE:<br>
> Unable to open datasource `PG:dbname=postgis user=postgres port=5437'<br>
> with the following drivers.<br>
>   -> FileGDB<br>
>   -> ESRI Shapefile<br>
>  [...]<br>
>   -> PostgreSQL<br>
>  [...]<br>
><br>
> As does any call to ogr2ogr. Yet this command succeeds:<br>
><br>
> C:\>ogrinfo --config PG_LIST_ALL_TABLES YES PG:"dbname=postgis<br>
> user=postgres port=5437"<br>
> INFO: Open of `PG:dbname=postgis user=postgres port=5437'<br>
>       using driver `PostgreSQL' successful.<br>
> 1: tiger.loader_variables (None)<br>
> 2: tiger.loader_lookuptables (None)<br>
> 3: raster_columns<br>
> [...]<br>
><br>
> This page <a href="http://www.gdal.org/drv_pg.html" rel="noreferrer" target="_blank">http://www.gdal.org/drv_pg.html</a> (see FAQs at the bottom)<br>
> suggests that permissions on geometry_columns and/or spatial_ref_sys<br>
> tables are the likely culprits, yet these tables appear to have full<br>
> permissions granted for user postgres.<br>
><br>
> Can anyone suggest a solution?<br>
><br>
> Many thanks for any assistance.<br>
><br>
> Chris<br>
><br>
> -- Versions:<br>
> PostgreSQL 9.5beta1, compiled by Visual C++ build 1800, 64-bit<br>
><br>
> POSTGIS="2.2.0 r14208" GEOS="3.5.0-CAPI-1.9.0 r4090" SFCGAL="1.2.0"<br>
> PROJ="Rel. 4.9.1, 04 March 2015" GDAL="GDAL 2.0.1, released 2015/09/15"<br>
> LIBXML="2.7.8" LIBJSON="0.12" TOPOLOGY RASTER<br>
><br>
> GDAL 1.11.3, released 2015/09/16<br>
><br>
> _______________________________________________<br>
> postgis-users mailing list<br>
> <a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a><br>
<br>
<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org">postgis-users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">http://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div><br></div></div>