Skip to content
Permalink
Browse files

Merge pull request #2923 from nyalldawson/fix_14407

Don't force use of SQL dialect when running ogr queries (fix #14407)
  • Loading branch information
jef-n committed Mar 23, 2016
2 parents 40611d7 + 8d9443b commit b24d5eaeb36460b048da3144e63768ebf72a18b9
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/providers/ogr/qgsogrprovider.cpp
@@ -1356,7 +1356,7 @@ bool QgsOgrProvider::createSpatialIndex()
{
QByteArray sql = "CREATE SPATIAL INDEX ON " + quotedIdentifier( layerName ); // quote the layer name so spaces are handled
QgsDebugMsg( QString( "SQL: %1" ).arg( FROM8( sql ) ) );
OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), "" );
OGR_DS_ExecuteSQL( ogrDataSource, sql.constData(), OGR_L_GetSpatialFilter( ogrOrigLayer ), nullptr );
}

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

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

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

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

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

0 comments on commit b24d5ea

Please sign in to comment.
You can’t perform that action at this time.