Skip to content
Permalink
Browse files

[postgres] Fix estimated metadata queries fail for huge tables

Fixes #21517
  • Loading branch information
nyalldawson committed Mar 8, 2019
1 parent 56ec3cf commit da2064d089bc04b7793026ee89c761a1ccc64789
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -3190,7 +3190,7 @@ long QgsPostgresProvider::featureCount() const
// - but make huge dataset usable.
if ( !mIsQuery && mUseEstimatedMetadata )
{
sql = QStringLiteral( "SELECT reltuples::int FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
sql = QStringLiteral( "SELECT reltuples::bigint FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
}
else
{
@@ -3249,7 +3249,7 @@ QgsRectangle QgsPostgresProvider::extent() const
{
if ( result.PQgetvalue( 0, 0 ).toInt() > 0 )
{
sql = QStringLiteral( "SELECT reltuples::int FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
sql = QStringLiteral( "SELECT reltuples::bigint FROM pg_catalog.pg_class WHERE oid=regclass(%1)::oid" ).arg( quotedValue( mQuery ) );
result = connectionRO()->PQexec( sql );
if ( result.PQresultStatus() == PGRES_TUPLES_OK
&& result.PQntuples() == 1

0 comments on commit da2064d

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