Skip to content

Commit 31c914d

Browse files
nyalldawsonjef-n
authored andcommittedMar 23, 2016
Don't force use of SQL dialect when running ogr queries (fix #14407)
Using "SQL" dialect is not recommended as it forces use of the sometimes buggy SDK query engines. This was breaking the uniqueValues method for ESRI gdb files. See https://trac.osgeo.org/gdal/ticket/6415 for GDAL dev recommendation to use default OGR dialect in place of "SQL" dialect. (cherry picked from commit 8d9443b)
1 parent 5278003 commit 31c914d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
 

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,7 +1356,7 @@ bool QgsOgrProvider::createSpatialIndex()
13561356
{
13571357
QByteArray sql = "CREATE SPATIAL INDEX ON " + quotedIdentifier( layerName ); // quote the layer name so spaces are handled
13581358
QgsDebugMsg( QString( "SQL: %1" ).arg( FROM8( sql ) ) );
1359-
OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );
1359+
OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
13601360
}
13611361

13621362
QFileInfo fi( mFilePath ); // to get the base name
@@ -1369,9 +1369,9 @@ bool QgsOgrProvider::createAttributeIndex( int field )
13691369
{
13701370
QByteArray quotedLayerName = quotedIdentifier( OGR_FD_GetName( OGR_L_GetLayerDefn( ogrOrigLayer ) ) );
13711371
QByteArray dropSql = "DROP INDEX ON " + quotedLayerName;
1372-
OGR_DS_ExecuteSQL( ogrDataSource, dropSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
1372+
OGR_DS_ExecuteSQL( ogrDataSource, dropSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
13731373
QByteArray createSql = "CREATE INDEX ON " + quotedLayerName + " USING " + mEncoding->fromUnicode( fields()[field].name() );
1374-
OGR_DS_ExecuteSQL( ogrDataSource, createSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "SQL" );
1374+
OGR_DS_ExecuteSQL( ogrDataSource, createSql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
13751375

13761376
QFileInfo fi( mFilePath ); // to get the base name
13771377
//find out, if the .idm file is there
@@ -2434,7 +2434,7 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
24342434
sql += " ORDER BY " + mEncoding->fromUnicode( fld.name() ) + " ASC"; // quoting of fieldname produces a syntax error
24352435

24362436
QgsDebugMsg( QString( "SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );
2437-
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, "SQL" );
2437+
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
24382438
if ( !l )
24392439
{
24402440
QgsDebugMsg( "Failed to execute SQL" );
@@ -2472,7 +2472,7 @@ QVariant QgsOgrProvider::minimumValue( int index )
24722472
sql += " WHERE " + mEncoding->fromUnicode( mSubsetString );
24732473
}
24742474

2475-
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, "SQL" );
2475+
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
24762476
if ( !l )
24772477
{
24782478
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );
@@ -2511,7 +2511,7 @@ QVariant QgsOgrProvider::maximumValue( int index )
25112511
sql += " WHERE " + mEncoding->fromUnicode( mSubsetString );
25122512
}
25132513

2514-
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, "SQL" );
2514+
OGRLayerH l = OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), nullptr, nullptr );
25152515
if ( !l )
25162516
{
25172517
QgsDebugMsg( QString( "Failed to execute SQL: %1" ).arg( mEncoding->toUnicode( sql ) ) );

0 commit comments

Comments
 (0)
Please sign in to comment.