Skip to content

Commit 61eea86

Browse files
committed
oracle provider: verify existence of layer style table before trying to retrieve a style
1 parent 1af74f7 commit 61eea86

File tree

2 files changed

+22
-22
lines changed

2 files changed

+22
-22
lines changed

src/providers/oracle/ocispatial/qsql_ocispatial.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3163,9 +3163,7 @@ bool QOCISpatialResult::exec()
31633163
qOraWarning( "Unable to get statement type:", d->err );
31643164
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult",
31653165
"Unable to get statement type" ), QSqlError::StatementError, d->err ) );
3166-
#ifdef QOCISPATIAL_DEBUG
3167-
qDebug() << "lastQuery()" << lastQuery();
3168-
#endif
3166+
qWarning( "type retrieval failed with statement:%s", lastQuery().toLocal8Bit().constData() );
31693167
return false;
31703168
}
31713169

@@ -3189,9 +3187,7 @@ bool QOCISpatialResult::exec()
31893187
qOraWarning( "unable to bind value: ", d->err );
31903188
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult", "Unable to bind value" ),
31913189
QSqlError::StatementError, d->err ) );
3192-
#ifdef QOCISPATIAL_DEBUG
3193-
qDebug() << "lastQuery()" << lastQuery();
3194-
#endif
3190+
qWarning( "bind failed with statement:%s", lastQuery().toLocal8Bit().constData() );
31953191
return false;
31963192
}
31973193

@@ -3202,9 +3198,7 @@ bool QOCISpatialResult::exec()
32023198
qOraWarning( "unable to execute statement:", d->err );
32033199
setLastError( qMakeError( QCoreApplication::translate( "QOCISpatialResult",
32043200
"Unable to execute statement" ), QSqlError::StatementError, d->err ) );
3205-
#ifdef QOCISPATIAL_DEBUG
3206-
qDebug() << "lastQuery()" << lastQuery();
3207-
#endif
3201+
qWarning( "execution failed with statement:%s", lastQuery().toLocal8Bit().constData() );
32083202
return false;
32093203
}
32103204

src/providers/oracle/qgsoracleprovider.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3402,19 +3402,25 @@ QGISEXTERN QString loadStyle( const QString &uri, QString &errCause )
34023402
QSqlQuery qry( *conn );
34033403

34043404
QString style;
3405-
if ( !qry.exec( QString( "SELECT styleQML FROM ("
3406-
"SELECT styleQML"
3407-
" FROM layer_styles"
3408-
" WHERE f_table_catalog=%1"
3409-
" AND f_table_schema=%2"
3410-
" AND f_table_name=%3"
3411-
" AND f_geometry_column=%4"
3412-
" ORDER BY useAsDefault DESC"
3413-
") WHERE rownum=1" )
3414-
.arg( QgsOracleConn::quotedValue( dsUri.database() ) )
3415-
.arg( QgsOracleConn::quotedValue( dsUri.schema() ) )
3416-
.arg( QgsOracleConn::quotedValue( dsUri.table() ) )
3417-
.arg( QgsOracleConn::quotedValue( dsUri.geometryColumn() ) ) ) )
3405+
if ( !qry.exec( "SELECT COUNT(*) FROM user_tables WHERE table_name='LAYER_STYLES'" ) || !qry.next() || qry.value( 0 ).toInt() == 0 )
3406+
{
3407+
errCause = QObject::tr( "Unable layer style table not found [%1]" ).arg( qry.lastError().text() );
3408+
conn->disconnect();
3409+
return QString::null;
3410+
}
3411+
else if ( !qry.exec( QString( "SELECT styleQML FROM ("
3412+
"SELECT styleQML"
3413+
" FROM layer_styles"
3414+
" WHERE f_table_catalog=%1"
3415+
" AND f_table_schema=%2"
3416+
" AND f_table_name=%3"
3417+
" AND f_geometry_column=%4"
3418+
" ORDER BY useAsDefault DESC"
3419+
") WHERE rownum=1" )
3420+
.arg( QgsOracleConn::quotedValue( dsUri.database() ) )
3421+
.arg( QgsOracleConn::quotedValue( dsUri.schema() ) )
3422+
.arg( QgsOracleConn::quotedValue( dsUri.table() ) )
3423+
.arg( QgsOracleConn::quotedValue( dsUri.geometryColumn() ) ) ) )
34183424
{
34193425
errCause = QObject::tr( "Could not retrieve style [%1]" ).arg( qry.lastError().text() );
34203426
}

0 commit comments

Comments
 (0)