You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve filtering by schema for postgres connections in browser
Results in much faster display and refresh of postgres tables
Also:
- ensure browser correctly respects postgres connection settings
- add schema comment tooltip and refresh context menu item
- make postgres connections less noisy in debug logs
Copy file name to clipboardExpand all lines: src/providers/postgres/qgspostgresconn.cpp
+68-24Lines changed: 68 additions & 24 deletions
Original file line number
Diff line number
Diff line change
@@ -302,7 +302,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty& layerProperty, co
302
302
QString sql = QString( "SELECT attname, CASE WHEN typname = ANY(ARRAY['geometry','geography','topogeometry']) THEN 1 ELSE null END AS isSpatial FROM pg_attribute JOIN pg_type ON atttypid=pg_type.oid WHERE attrelid=regclass('%1.%2')" )
303
303
.arg( quotedIdentifier( schemaName ) )
304
304
.arg( quotedIdentifier( viewName ) );
305
-
QgsDebugMsg( sql );
305
+
//QgsDebugMsg( sql );
306
306
QgsPostgresResult colRes = PQexec( sql );
307
307
308
308
layerProperty.pkCols.clear();
@@ -314,7 +314,7 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty& layerProperty, co
314
314
{
315
315
if ( fetchPkCandidates )
316
316
{
317
-
QgsDebugMsg( colRes.PQgetvalue( i, 0 ) );
317
+
//QgsDebugMsg( colRes.PQgetvalue( i, 0 ) );
318
318
layerProperty.pkCols << colRes.PQgetvalue( i, 0 );
319
319
}
320
320
@@ -331,14 +331,14 @@ void QgsPostgresConn::addColumnInfo( QgsPostgresLayerProperty& layerProperty, co
QgsMessageLog::logMessage( tr( "Database connection was successful, but no accessible tables were found. Please verify that you have SELECT privilege on a table carrying PostGIS geometry." ), tr( "PostGIS" ) );
652
+
QgsMessageLog::logMessage( tr( "Database connection was successful, but the accessible tables could not be determined." ), tr( "PostGIS" ) );
QString sql = QString( "SELECT nspname, pg_get_userbyid(nspowner), pg_catalog.obj_description(oid) FROM pg_namespace WHERE nspname !~ '^pg_' AND nspname != 'information_schema' ORDER BY nspname" );
651
680
681
+
result = PQexec( sql, true );
682
+
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
683
+
{
684
+
PQexecNR( "COMMIT" );
685
+
returnfalse;
686
+
}
687
+
688
+
for ( int idx = 0; idx < result.PQntuples(); idx++ )
0 commit comments