Skip to content

Commit 4ba3290

Browse files
committedOct 18, 2016
[postgres] Avoid crash when fetching default value fails
1 parent 321017f commit 4ba3290

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,13 @@ QVariant QgsPostgresProvider::defaultValue( int fieldId )
17241724

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

1727-
return convertValue( fld.type(), res.PQgetvalue( 0, 0 ) );
1727+
if ( res.result() )
1728+
return convertValue( fld.type(), res.PQgetvalue( 0, 0 ) );
1729+
else
1730+
{
1731+
pushError( tr( "Could not execute query" ) );
1732+
return QVariant();
1733+
}
17281734
}
17291735

17301736
return defVal;

0 commit comments

Comments
 (0)
Please sign in to comment.