Should bomb out when given multiple -sql arguments, instead of randomly executing one
What is the bug?
As per #9394, the programs should bomb out when given multiple -sql arguments, instead of the current behavior of simply "randomly" executing one of them as if that was the only one given.
Stopping it is a better idea than attempting to document this aberrant behavior.
I do not remember any user feedback about surprises with giving multiple -sql arguments. I believe that it is not a very common problem, and I also believe that it has made some trouble for someone sometimes.
Definition of aberrant seems to be "different from what is typical or usual". It is typical and usual for GDAL that users are not protected against giving several times arguments that can be used only once. I do not mean that it is perfect solution to force users to read the documentation.
All I know is -sql statement1 -sql statement2 is equivalent to -sql 'statement1; statement2;' and that causes an error to be raised.
Another variation:
ogrinfo test.gpkg test -where fid=1 -where fid=2
What error do you see with -sql 'statement1; statement2;'? I do not see any
ogrinfo pyykkitarkastus.gpkg -sql "select * from pyykkitarkastus where fid=2;select * from pyykkitarkastus where fid=1"
INFO: Open of `pyykkitarkastus.gpkg'
using driver `GPKG' successful.
Layer name: SELECT
Geometry: Point
Feature Count: 1
...
Wondering if we shouldn't investigate on using a "standard" argument parser that would provide all the convenient logic, such as erroring out if provided multiple arguments when this is not expected. https://github.com/p-ranav/argparse could be a candidate to investigate
What error do you see with
-sql 'statement1; statement2;'? I do not see any
$ ogr2ogr o.csv x.csv -sql 'SELECT 1 FROM x; SELECT 2 FROM x;'
ERROR 1: SQL Expression Parsing Error: syntax error, unexpected $undefined, expecting end of string. Occurred around :
SELECT 1 FROM x; SELECT 2 FROM x;
^
Ok, that seems to happen with the OGRSQL dialect.
indeed the multiple instances of arguments in various utils has bitten me a few times
Check of single -sql instance is now effective in ogrinfo, ogr2ogr and gdal_grid which have been converted to the argparse framework. Still remaining gdal_rasterize