Skip to content
Permalink
Browse files

[postgres] Avoid crash when fetching default value fails

  • Loading branch information
m-kuhn committed Oct 18, 2016
1 parent 321017f commit 4ba3290aa4db232d5ec265a2fafe47a61e6ea8b5
Showing with 7 additions and 1 deletion.
  1. +7 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -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;

0 comments on commit 4ba3290

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