When executing a SQL statement via the DuckDB ODBC interface using bind parameters, the presence of a Spatial function causes all sorts of errors, many of which are not obvious.
Let's start with the following C program which we use to test simple spatial capabilities of databases with a spatial type that support an ODBC interface:
When executing a SQL statement via the DuckDB ODBC interface using bind parameters, the presence of a Spatial function causes all sorts of errors, many of which are not obvious.
Let's start with the following C program which we use to test simple spatial capabilities of databases with a spatial type that support an ODBC interface:
Running it with a DSN of the form:
DRIVER={DuckDB Driver};Database=C:\xxx\experiment1.duckdb
produces the following error:Which is an odd error to get from SQLPrepare.
Interestingly, if we change ST_GEOMFROMTEXT to ST_GEOMFROMGEOJSON or ST_GEOMFROMWKB, we get:
Which is also a strange error to get from SQLPrepare.
Changing the function to ST_GEOMFROMHEXWKB gets us past the SQLPrepare:
But the new error is not what one would expect, either.
Making the argument to ST_GEOMFROMTEXT fixed to 'POINT (1.1 1.1)' and removing the corresponding SQLBindParameter call, we get:
Which is not right.
Taking the NOT NULL specifier off of OBJECTID (and keeping the above change), the program hangs on SQLExecute with the following call stack:
However, if we take out all of the binds:
It runs fine:
Tests run on Windows 10 Enterprise, x64 using DuckDB 0.10.2 and 5/28/2024 bleeding edge.
Peter Aronson, Esri.