Skip to content
Permalink
Browse files

postgres provider: allow database without postgis (fixes #6891)

(cherry picked from commit 94413b3)
  • Loading branch information
jef-n committed Jun 20, 2016
1 parent 4915d76 commit 57c199f3e47de1b367e7f44687e57d640c911c57
Showing with 17 additions and 20 deletions.
  1. +17 −20 src/providers/postgres/qgspostgresconn.cpp
@@ -290,32 +290,28 @@ QgsPostgresConn::QgsPostgresConn( const QString& conninfo, bool readOnly, bool s
deduceEndian();

/* Check to see if we have working PostGIS support */
if ( postgisVersion().isNull() )
if ( !postgisVersion().isNull() )
{
QgsMessageLog::logMessage( tr( "Your database has no working PostGIS support." ), tr( "PostGIS" ) );
PQfinish();
mRef = 0;
return;
/* Check to see if we have GEOS support and if not, warn the user about
the problems they will see :) */
QgsDebugMsg( "Checking for GEOS support" );

if ( !hasGEOS() )
{
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" ) );
}

if ( hasTopology() )
{
QgsDebugMsg( "Topology support available!" );
}
}

if ( mPostgresqlVersion >= 90000 )
{
PQexecNR( "SET application_name='QGIS'" );
}

/* Check to see if we have GEOS support and if not, warn the user about
the problems they will see :) */
QgsDebugMsg( "Checking for GEOS support" );

if ( !hasGEOS() )
{
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" ) );
}

if ( hasTopology() )
{
QgsDebugMsg( "Topology support available!" );
}

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

mPostgresqlVersion = PQserverVersion( mConn );

QgsPostgresResult result( PQexec( "SELECT postgis_version()" ) );
QgsPostgresResult result( PQexec( "SELECT postgis_version()", false ) );
if ( result.PQntuples() != 1 )
{
QgsMessageLog::logMessage( tr( "Retrieval of postgis version failed" ), tr( "PostGIS" ) );
QgsMessageLog::logMessage( tr( "No PostGIS support in the database." ), tr( "PostGIS" ) );
mGotPostgisVersion = true;
return QString::null;
}

0 comments on commit 57c199f

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