OGR SQL dialect and SQLITE SQL dialect

The GDALDataset supports executing commands against a datasource via the GDALDataset::ExecuteSQL() method. How such commands are evaluated is dependent on the datasets.



SQL is executed against an GDALDataset, not against a specific layer. The call looks like this:

OGRLayer * GDALDataset::ExecuteSQL( const char *pszSQLCommand,
                                    OGRGeometry *poSpatialFilter,
                                    const char *pszDialect );

The pszDialect argument is in theory intended to allow for support of different command languages against a provider, but for now applications should always pass an empty (not NULL) string to get the default dialect.

The poSpatialFilter argument is a geometry used to select a bounding rectangle for features to be returned in a manner similar to the OGRLayer::SetSpatialFilter() method. It may be NULL for no special spatial restriction.

The result of an ExecuteSQL() call is usually a temporary OGRLayer representing the results set from the statement. This is the case for a SELECT statement for instance. The returned temporary layer should be released with GDALDataset::ReleaseResultsSet() method when no longer needed. Failure to release it before the datasource is destroyed may result in a crash.