Skip to content

Commit

Permalink
[postgres] Avoid crash when fetching default value fails
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Oct 18, 2016
1 parent 321017f commit 4ba3290
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1724,7 +1724,13 @@ QVariant QgsPostgresProvider::defaultValue( int fieldId )

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

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

return defVal;
Expand Down

0 comments on commit 4ba3290

Please sign in to comment.