Skip to content

Commit c1065b9

Browse files
committedJun 7, 2011
Fix feature count for postgres provider so it doesn't use estimated metadata when reporting results of a subset in the query builder
1 parent 03525ea commit c1065b9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed
 

‎src/providers/postgres/qgspostgresprovider.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,9 @@ long QgsPostgresProvider::featureCount() const
28902890
// get total number of features
28912891
QString sql;
28922892

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

2909+
29072910
Result result = connectionRO->PQexec( sql );
29082911

29092912
QgsDebugMsg( "number of features as text: " +

0 commit comments

Comments
 (0)
Please sign in to comment.