Skip to content

Commit 9a584ed

Browse files
author
jef
committed
put out a warning message when no accessible postgis tables were found
git-svn-id: http://svn.osgeo.org/qgis/trunk@8286 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent c598dc2 commit 9a584ed

File tree

1 file changed

+23
-14
lines changed

1 file changed

+23
-14
lines changed

src/app/qgsdbsourceselect.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -536,30 +536,39 @@ bool QgsDbSourceSelect::getTableInfo(PGconn *pg, bool searchGeometryColumnsOnly,
536536
PGresult *result = PQexec(pg, sql.toUtf8());
537537
if (result)
538538
{
539-
for (int idx = 0; idx < PQntuples(result); idx++)
539+
if( PQntuples(result)==0 )
540+
{
541+
QMessageBox::warning(this, tr("No accessible tables found"),
542+
tr
543+
("Database connection was successful, but no accessible tables were found.\n\n"
544+
"Please verify that you have SELECT privilege on a PostGIS' geometry_columns\n"
545+
"table and at least one table carrying PostGIS geometry."));
546+
}
547+
else
540548
{
541-
QString tableName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_name").toUtf8())));
542-
QString schemaName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_schema").toUtf8())));
549+
for (int idx = 0; idx < PQntuples(result); idx++)
550+
{
551+
QString tableName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_name").toUtf8())));
552+
QString schemaName = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_table_schema").toUtf8())));
543553

544-
QString column = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_geometry_column").toUtf8())));
545-
QString type = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("type").toUtf8())));
554+
QString column = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("f_geometry_column").toUtf8())));
555+
QString type = QString::fromUtf8(PQgetvalue(result, idx, PQfnumber(result, QString("type").toUtf8())));
546556

547-
QString as = "";
548-
if(type=="GEOMETRY" && !searchGeometryColumnsOnly)
549-
{
550-
addSearchGeometryColumn(schemaName, tableName, column);
551-
as=type="WAITING";
552-
}
557+
QString as = "";
558+
if(type=="GEOMETRY" && !searchGeometryColumnsOnly)
559+
{
560+
addSearchGeometryColumn(schemaName, tableName, column);
561+
as=type="WAITING";
562+
}
553563

554-
mTableModel.addTableEntry(type, schemaName, tableName, column, "");
564+
mTableModel.addTableEntry(type, schemaName, tableName, column, "");
565+
}
555566
}
556567
ok = true;
557568
}
558569
PQclear(result);
559570

560571
//search for geometry columns in tables that are not in the geometry_columns metatable
561-
562-
563572
QApplication::restoreOverrideCursor();
564573
if (searchGeometryColumnsOnly)
565574
{

0 commit comments

Comments
 (0)