Skip to content
Permalink
Browse files

[postgres] Avoid crash when fetching default value fails

  • Loading branch information
m-kuhn committed Oct 21, 2016
1 parent 81e86ac commit 04e3796610042fb7b2d86caccd50516248b95533
@@ -606,7 +606,7 @@ QStringList QgsVectorDataProvider::errors() const
return mErrors;
}

void QgsVectorDataProvider::pushError( const QString& msg )
void QgsVectorDataProvider::pushError( const QString& msg ) const
{
QgsDebugMsg( msg );
mErrors << msg;
@@ -722,4 +722,4 @@ QStringList QgsVectorDataProvider::smEncodings;
QList<QgsRelation> QgsVectorDataProvider::discoverRelations( const QgsVectorLayer*, const QList<QgsVectorLayer*>& ) const
{
return QList<QgsRelation>();
}
}
@@ -445,7 +445,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider

signals:
/** Signals an error in this provider */
void raiseError( const QString& msg );
void raiseError( const QString& msg ) const;

protected:
void clearMinMaxCache();
@@ -465,7 +465,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
/** The names of the providers native types*/
QList< NativeType > mNativeTypes;

void pushError( const QString& msg );
void pushError( const QString& msg ) const;

/** Old-style mapping of index to name for QgsPalLabeling fix */
QgsAttrPalIndexNameHash mAttrPalIndexName;
@@ -479,7 +479,7 @@ class CORE_EXPORT QgsVectorDataProvider : public QgsDataProvider
QMap<QString, QVariant::Type> mOldTypeList;

/** List of errors */
QStringList mErrors;
mutable QStringList mErrors;

static QStringList smEncodings;

@@ -1707,7 +1707,13 @@ QVariant QgsPostgresProvider::defaultValue( int fieldId ) const

QgsPostgresResult res( connectionRO()->PQexec( QString( "SELECT %1" ).arg( defVal.toString() ) ) );

return convertValue( fld.type(), fld.subType(), res.PQgetvalue( 0, 0 ) );
if ( res.result() )
return convertValue( fld.type(), fld.subType(), res.PQgetvalue( 0, 0 ) );
else
{
pushError( tr( "Could not execute query" ) );
return QVariant();
}
}

return defVal;

0 comments on commit 04e3796

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