Skip to content
Permalink
Browse files

[postgres] Fix estimated metadata queries fail for huge tables

Fixes #21517
  • Loading branch information
nyalldawson committed Mar 14, 2019
1 parent fb6b3a7 commit aba1e308f06ae7330783db408f87001324448fd9
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/providers/postgres/qgspostgresprovider.cpp
@@ -3187,7 +3187,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
{
@@ -3246,7 +3246,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 aba1e30

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