Skip to content

Commit

Permalink
Fix feature count for postgres provider so it doesn't use estimated m…
Browse files Browse the repository at this point in the history
…etadata when reporting results of a subset in the query builder
  • Loading branch information
g-sherman committed Jun 7, 2011
1 parent 03525ea commit c1065b9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2890,7 +2890,9 @@ long QgsPostgresProvider::featureCount() const
// get total number of features
QString sql;

if ( !isQuery && mUseEstimatedMetadata )
// only use estimated metadata when there is no where clause, otherwise
// we get an incorrect feature count for the subset
if ( !isQuery && mUseEstimatedMetadata && sqlWhereClause.isEmpty())
{
sql = QString( "select reltuples::int from pg_catalog.pg_class where oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
}
Expand All @@ -2904,6 +2906,7 @@ long QgsPostgresProvider::featureCount() const
}
}


Result result = connectionRO->PQexec( sql );

QgsDebugMsg( "number of features as text: " +
Expand Down

0 comments on commit c1065b9

Please sign in to comment.