Skip to content
Permalink
Browse files

[oracle] Fix minor Coverity issues

(cherry-picked from b94fbc0)
  • Loading branch information
nyalldawson committed Jul 19, 2016
1 parent 8784312 commit 09cc75964557a5645c2ef21a8a64a5c8dd7c47d6
@@ -31,7 +31,7 @@ QMap<QString, QgsOracleConn *> QgsOracleConn::sConnections;
int QgsOracleConn::snConnections = 0;
const int QgsOracleConn::sGeomTypeSelectLimit = 100;

QgsOracleConn *QgsOracleConn::connectDb( QgsDataSourceURI uri )
QgsOracleConn *QgsOracleConn::connectDb( const QgsDataSourceURI& uri )
{
QString conninfo = toPoolName( uri );
if ( sConnections.contains( conninfo ) )
@@ -140,7 +140,7 @@ QgsOracleConn::~QgsOracleConn()
mDatabase.close();
}

QString QgsOracleConn::toPoolName( QgsDataSourceURI uri )
QString QgsOracleConn::toPoolName( const QgsDataSourceURI &uri )
{
QString conninfo = uri.connectionInfo();
if ( uri.hasParam( "dbworkspace" ) )
@@ -45,6 +45,10 @@ struct QgsOracleLayerProperty
QStringList pkCols;
QString sql;

QgsOracleLayerProperty()
: isView( false )
{}

int size() const { Q_ASSERT( types.size() == srids.size() ); return types.size(); }

bool operator==( const QgsOracleLayerProperty& other )
@@ -107,7 +111,7 @@ class QgsOracleConn : public QObject
{
Q_OBJECT
public:
static QgsOracleConn *connectDb( QgsDataSourceURI uri );
static QgsOracleConn *connectDb( const QgsDataSourceURI &uri );
void disconnect();

/** Double quote a Oracle identifier for placement in a SQL string.
@@ -160,7 +164,7 @@ class QgsOracleConn : public QObject
static bool onlyExistingTypes( QString theConnName );
static void deleteConnection( QString theConnName );
static QString databaseName( QString database, QString host, QString port );
static QString toPoolName( QgsDataSourceURI uri );
static QString toPoolName( const QgsDataSourceURI& uri );

operator QSqlDatabase() { return mDatabase; }

@@ -25,7 +25,7 @@ inline QString qgsConnectionPool_ConnectionToName( QgsOracleConn* c )
return c->connInfo();
}

inline void qgsConnectionPool_ConnectionCreate( QgsDataSourceURI uri, QgsOracleConn*& c )
inline void qgsConnectionPool_ConnectionCreate( const QgsDataSourceURI& uri, QgsOracleConn*& c )
{
c = QgsOracleConn::connectDb( uri );
}
@@ -1863,7 +1863,6 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
g.eleminfo.clear();
g.ordinates.clear();

QString expr;
int iOrdinate = 1;
QGis::WkbType type = ( QGis::WkbType ) * ptr.iPtr++;
int dim = 2;
@@ -1872,6 +1871,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
{
case QGis::WKBPoint25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBPoint:
g.srid = mSrid;
g.gtype = SDO_GTYPE( dim, gtPoint );
@@ -1883,6 +1884,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
case QGis::WKBLineString25D:
case QGis::WKBMultiLineString25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBLineString:
case QGis::WKBMultiLineString:
{
@@ -1918,6 +1921,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry
case QGis::WKBPolygon25D:
case QGis::WKBMultiPolygon25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBPolygon:
case QGis::WKBMultiPolygon:
{
@@ -1957,6 +1962,8 @@ void QgsOracleProvider::appendGeomParam( const QgsGeometry *geom, QSqlQuery &qry

case QGis::WKBMultiPoint25D:
dim = 3;
FALLTHROUGH;

case QGis::WKBMultiPoint:
{
g.gtype = SDO_GTYPE( dim, gtMultiPoint );
@@ -2830,7 +2837,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(

QgsDebugMsg( QString( "layer %1 created" ).arg( ownerTableName ) );

// use the provider to edit the table
// use the provider to edit the table1
dsUri.setDataSource( ownerName, tableName, geometryColumn, QString(), primaryKey );
QgsOracleProvider *provider = new QgsOracleProvider( dsUri.uri() );
if ( !provider->isValid() )
@@ -2845,8 +2852,7 @@ QgsVectorLayerImport::ImportError QgsOracleProvider::createEmptyLayer(
QgsDebugMsg( "layer loaded" );

// add fields to the layer
if ( oldToNewAttrIdxMap )
oldToNewAttrIdxMap->clear();
oldToNewAttrIdxMap->clear();

if ( fields.size() > 0 )
{
@@ -410,7 +410,6 @@ class QgsOracleProvider : public QgsVectorDataProvider
QgsFeatureId mFidCounter; //! next feature id if map is used
QgsOracleConn *mConnection;

bool mHasSpatial; //! Oracle Spatial is installed
bool mHasSpatialIndex; //! Geometry column is indexed
QString mSpatialIndexName; //! name of spatial index of geometry column

0 comments on commit 09cc759

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