Skip to content
Permalink
Browse files
Warn the user if PostGIS isn't in the selected database
git-svn-id: http://svn.osgeo.org/qgis/trunk@5966 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
g_j_m committed Oct 17, 2006
1 parent 6a53975 commit 60ef2d64cc7050db28dc2208cd85c2b1b51426a7
Showing with 23 additions and 1 deletion.
  1. +23 −1 src/plugins/spit/qgsspit.cpp
@@ -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;
}

0 comments on commit 60ef2d6

Please sign in to comment.