Skip to content

Commit 57c199f

Browse files
committedJun 26, 2016
postgres provider: allow database without postgis (fixes #6891)
(cherry picked from commit 94413b3)
1 parent 4915d76 commit 57c199f

File tree

1 file changed

+17
-20
lines changed

1 file changed

+17
-20
lines changed
 

‎src/providers/postgres/qgspostgresconn.cpp

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -290,32 +290,28 @@ QgsPostgresConn::QgsPostgresConn( const QString& conninfo, bool readOnly, bool s
290290
deduceEndian();
291291

292292
/* Check to see if we have working PostGIS support */
293-
if ( postgisVersion().isNull() )
293+
if ( !postgisVersion().isNull() )
294294
{
295-
QgsMessageLog::logMessage( tr( "Your database has no working PostGIS support." ), tr( "PostGIS" ) );
296-
PQfinish();
297-
mRef = 0;
298-
return;
295+
/* Check to see if we have GEOS support and if not, warn the user about
296+
the problems they will see :) */
297+
QgsDebugMsg( "Checking for GEOS support" );
298+
299+
if ( !hasGEOS() )
300+
{
301+
QgsMessageLog::logMessage( tr( "Your PostGIS installation has no GEOS support. Feature selection and identification will not work properly. Please install PostGIS with GEOS support (http://geos.refractions.net)" ), tr( "PostGIS" ) );
302+
}
303+
304+
if ( hasTopology() )
305+
{
306+
QgsDebugMsg( "Topology support available!" );
307+
}
299308
}
300309

301310
if ( mPostgresqlVersion >= 90000 )
302311
{
303312
PQexecNR( "SET application_name='QGIS'" );
304313
}
305314

306-
/* Check to see if we have GEOS support and if not, warn the user about
307-
the problems they will see :) */
308-
QgsDebugMsg( "Checking for GEOS support" );
309-
310-
if ( !hasGEOS() )
311-
{
312-
QgsMessageLog::logMessage( tr( "Your PostGIS installation has no GEOS support. Feature selection and identification will not work properly. Please install PostGIS with GEOS support (http://geos.refractions.net)" ), tr( "PostGIS" ) );
313-
}
314-
315-
if ( hasTopology() )
316-
{
317-
QgsDebugMsg( "Topology support available!" );
318-
}
319315

320316
PQsetNoticeProcessor( mConn, noticeProcessor, nullptr );
321317
}
@@ -836,10 +832,11 @@ QString QgsPostgresConn::postgisVersion()
836832

837833
mPostgresqlVersion = PQserverVersion( mConn );
838834

839-
QgsPostgresResult result( PQexec( "SELECT postgis_version()" ) );
835+
QgsPostgresResult result( PQexec( "SELECT postgis_version()", false ) );
840836
if ( result.PQntuples() != 1 )
841837
{
842-
QgsMessageLog::logMessage( tr( "Retrieval of postgis version failed" ), tr( "PostGIS" ) );
838+
QgsMessageLog::logMessage( tr( "No PostGIS support in the database." ), tr( "PostGIS" ) );
839+
mGotPostgisVersion = true;
843840
return QString::null;
844841
}
845842

0 commit comments

Comments
 (0)
Please sign in to comment.