Skip to content

Commit

Permalink
Warn the user if PostGIS isn't in the selected database
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5966 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Oct 17, 2006
1 parent 58c5231 commit 55b1d3d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/plugins/spit/qgsspit.cpp
Expand Up @@ -427,8 +427,30 @@ PGconn* QgsSpit::checkConnection()
result = false;
}
}
if ( result )

if (result )
{
// Check that the database actually has postgis in it.
QString sql1 = "SELECT postgis_lib_version()"; // available from v 0.9.0 onwards
QString sql2 = "SELECT postgis_version()"; // depreciated

PGresult* ver = PQexec(pd, sql1.toLocal8Bit().data());
if ( PQresultStatus(ver) != PGRES_TUPLES_OK)
{
// In case the version of postgis is older than 0.9.0, try the
// depreciated call before erroring out.
PQclear(ver);
ver = PQexec(pd, sql2.toLocal8Bit().data());
if ( PQresultStatus(ver) != PGRES_TUPLES_OK)
{
QMessageBox::warning( this, tr("PostGIS not available"),
tr("<p>The chosen database does not have PostGIS installed, "
"but this is required for storage of spatial data.</p>"));
return NULL;
}
}
return pd;
}
else
return NULL;
}
Expand Down

0 comments on commit 55b1d3d

Please sign in to comment.