Skip to content

Commit

Permalink
postgres provider: allow database without postgis (fixes #6891)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Jun 20, 2016
1 parent ecf3b37 commit 94413b3
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/providers/postgres/qgspostgresconn.cpp
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 94413b3

Please sign in to comment.