Skip to content

Commit

Permalink
postgres provider: allow database without postgis (fixes #6891)
Browse files Browse the repository at this point in the history
(cherry picked from commit 94413b3)
  • Loading branch information
jef-n committed Jun 26, 2016
1 parent 4915d76 commit 57c199f
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/providers/postgres/qgspostgresconn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 57c199f

Please sign in to comment.