-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unable to connect to data source when querying information_schema.columns is_updateable column #163
Comments
Forgot to mention I tested this on GDAL 2.4.0 and GDAL 2.2.4, latest release version of ogr_fdw. |
Okay I tried to work around the problem by setting updateable to false
Gives error:
I forgot to mention I am testing on PostgreSQL 11.2 if that makes a difference. |
Other interesting oddities, if I try to set updateable to true, I immediately get the error:
|
Here is the offending query reduced to it's most basic:
If updateable is set to false, get:
As mentioned with the updateable not set or set to true, it gives the:
|
A similar problem: This fairly standard metadata query is used by PostgREST at startup.
It throws an error, so PostgREST fails to start if any ogr_fdw foreign table exists in the current database. The query works without the pg_relation_is_updatable() function call. |
I'm feeling a little painted into the corner by OGR here. @rouault maybe can help... If you open a read/write data source with Except, if you open a read-only data source, like an "OpenFileGDB" source, with Failing in this way is probably OK for operations like INSERT/UPDATE/DELETE: they aren't going to work to where precisely they fail in the flow of things isn't so important. But unfortunately the test of "is this thing writeable at all" which is happening here requires a conditional attempt to open with Failing some magic solution from @rouault that I'm not seeing this will involve some kind of major ugliness and refactoring of how I'm opening OGR connections, which as you can imagine is rather central to this whole extension. :( |
If you open in update mode a dataset that can only be supported in read-only mode, GDALOpenEx() will silently return a NULL pointer and not emit an error. You can just retry in read-only mode then. Demo (in Python for conveniency, but behaviour will be identical with C API
|
I'm seeing a trip to the error handler when I make that call.
So a |
|
Hum, nOpenFlags=69 = 1 + 4 + 64 = GDAL_OF_UPDATE + GDAL_OF_VECTOR + GDAL_OF_VERBOSE_ERROR
Depends... sometimes they can be recovered. It might happen in very rare cases (partially corrupted datasets), that GDALOpenEx() returns a non-NULL handle, but that along the road, deep in the guts of drivers, a CPLError(CE_Failure, ...) was emitted. (side note: CE_Fatal crashes the process, and I think we have eliminated all of them from the code base, years ago) |
OK, yes, I had put in |
Should setting the foreign server as updateable = 'false' avoid the situation where querying updateability throws an error? |
Maybe it should but as it stands it doesn't, and fixing that is just one case in the overall schmozzle ;) |
I haven't tested all the potential combinations of readonly / readable / updateable yet, but master as of 5bad13a is closer to what you want, I think. |
Seems to work for a few use cases, and for regression. |
Both example queries mentioned here work if the foreign server is set to updateable = 'false'. Thank you! |
Did u solve this sir? CREATE SERVER access_server ERROR: GDAL AppDefined [1] GDALOpen() called on C:\dbPIB.mdb recursively I'm really confused |
This is not an issue with all GDAL drivers, but I ran into the problem with excel spreadsheets and also see the Querying.gdb (in your Querying.zip file) has the same issue.
Steps to reproduce:
Yields error:
However if you do:
That works fine. I isolated the issue to the last column in informaton_schema.columns called is_updateable, which calls the function:
pg_catalog.pg_column_is_updatable(regclass, smallint, boolean)
This issue doesn't seem to occur for all drivers. For example when I use the ESRI Shapefile one, I don't get this issue.
The text was updated successfully, but these errors were encountered: