mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Warn the user if PostGIS isn't in the selected database
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5966 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
parent
58c523153d
commit
55b1d3d178
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user