[SCM] qgis branch, master, updated. a2ee769957385f4e084c5e8b6ba178a8c877d1db
Juergen E. Fischer
jef at norbit.de
Tue Mar 20 13:42:50 UTC 2012
The following commit has been merged in the master branch:
commit c58debc638f2c87933dd371710bd107d3c7a5092
Author: Juergen E. Fischer <jef at norbit.de>
Date: Mon Mar 5 20:23:47 2012 +0100
postgresql provider: don't require access to geometry_columns
diff --git a/src/providers/postgres/qgspostgresconn.cpp b/src/providers/postgres/qgspostgresconn.cpp
index d47a339..47de53e 100644
--- a/src/providers/postgres/qgspostgresconn.cpp
+++ b/src/providers/postgres/qgspostgresconn.cpp
@@ -349,44 +349,38 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
if ( result.PQresultStatus() != PGRES_TUPLES_OK )
{
PQexecNR( "COMMIT" );
-
- if ( i == 0 )
- return false;
-
continue;
}
- else
+
+ nGTables++;
+
+ for ( int idx = 0; idx < result.PQntuples(); idx++ )
{
- nGTables++;
+ QString tableName = result.PQgetvalue( idx, 0 );
+ QString schemaName = result.PQgetvalue( idx, 1 );
+ QString column = result.PQgetvalue( idx, 2 );
+ QString type = result.PQgetvalue( idx, 3 );
+ QString srid = result.PQgetvalue( idx, 4 );
+ QString relkind = result.PQgetvalue( idx, 5 );
+
+ QgsDebugMsg( QString( "%1 : %2.%3.%4: %5 %6 %7" )
+ .arg( gtableName )
+ .arg( schemaName ).arg( tableName ).arg( column )
+ .arg( type )
+ .arg( srid )
+ .arg( relkind ) );
+
+ layerProperty.type = type;
+ layerProperty.schemaName = schemaName;
+ layerProperty.tableName = tableName;
+ layerProperty.geometryColName = column;
+ layerProperty.pkCols = relkind == "v" ? pkCandidates( schemaName, tableName ) : QStringList();
+ layerProperty.srid = srid;
+ layerProperty.sql = "";
+ layerProperty.isGeography = i == 1;
- for ( int idx = 0; idx < result.PQntuples(); idx++ )
- {
- QString tableName = result.PQgetvalue( idx, 0 );
- QString schemaName = result.PQgetvalue( idx, 1 );
- QString column = result.PQgetvalue( idx, 2 );
- QString type = result.PQgetvalue( idx, 3 );
- QString srid = result.PQgetvalue( idx, 4 );
- QString relkind = result.PQgetvalue( idx, 5 );
-
- QgsDebugMsg( QString( "%1 : %2.%3.%4: %5 %6 %7" )
- .arg( gtableName )
- .arg( schemaName ).arg( tableName ).arg( column )
- .arg( type )
- .arg( srid )
- .arg( relkind ) );
-
- layerProperty.type = type;
- layerProperty.schemaName = schemaName;
- layerProperty.tableName = tableName;
- layerProperty.geometryColName = column;
- layerProperty.pkCols = relkind == "v" ? pkCandidates( schemaName, tableName ) : QStringList();
- layerProperty.srid = srid;
- layerProperty.sql = "";
- layerProperty.isGeography = i == 1;
-
- mLayersSupported << layerProperty;
- nColumns++;
- }
+ mLayersSupported << layerProperty;
+ nColumns++;
}
}
diff --git a/src/providers/postgres/qgspostgresprovider.cpp b/src/providers/postgres/qgspostgresprovider.cpp
index edfba5c..5060e29 100644
--- a/src/providers/postgres/qgspostgresprovider.cpp
+++ b/src/providers/postgres/qgspostgresprovider.cpp
@@ -2682,10 +2682,14 @@ bool QgsPostgresProvider::getGeometryDetails()
detectedType = result.PQgetvalue( 0, 0 );
detectedSrid = result.PQgetvalue( 0, 1 );
}
+ else
+ {
+ mConnectionRO->PQexecNR( "COMMIT" );
+ }
- if ( !detectedType.isEmpty() )
+ if ( detectedType.isEmpty() )
{
- // check geometry columns
+ // check geography columns
sql = QString( "SELECT upper(type),srid FROM geography_columns WHERE f_table_name=%1 AND f_geography_column=%2 AND f_table_schema=%3" )
.arg( quotedValue( tableName ) )
.arg( quotedValue( geomCol ) )
@@ -2695,18 +2699,15 @@ bool QgsPostgresProvider::getGeometryDetails()
result = mConnectionRO->PQexec( sql, false );
QgsDebugMsg( QString( "Geography column query returned %1" ).arg( result.PQntuples() ) );
- if ( result.PQresultStatus() == PGRES_TUPLES_OK )
+ if ( result.PQntuples() == 1 )
{
- if ( result.PQntuples() == 1 )
- {
- detectedType = result.PQgetvalue( 0, 0 );
- detectedSrid = result.PQgetvalue( 0, 1 );
- mIsGeography = true;
- }
+ detectedType = result.PQgetvalue( 0, 0 );
+ detectedSrid = result.PQgetvalue( 0, 1 );
+ mIsGeography = true;
}
else
{
- mConnectionRO->PQexecNR( "ROLLBACK" );
+ mConnectionRO->PQexecNR( "COMMIT" );
}
}
}
--
The Quantum GIS in Debian project
More information about the Pkg-grass-devel
mailing list