Skip to content

Commit

Permalink
implement #1087
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@8444 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 15, 2008
1 parent 49e19e6 commit 64e827a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/qgsdbsourceselect.cpp
Expand Up @@ -591,17 +591,20 @@ bool QgsDbSourceSelect::getTableInfo(PGconn *pg, bool searchGeometryColumnsOnly,
sql = "select pg_class.relname,pg_namespace.nspname,pg_attribute.attname,pg_class.relkind "
"from pg_attribute, pg_class, pg_namespace "
"where pg_namespace.oid = pg_class.relnamespace "
"and pg_attribute.atttypid = regtype('geometry') "
"and pg_attribute.attrelid = pg_class.oid "
"and ("
"pg_attribute.atttypid = regtype('geometry')"
" or "
"pg_attribute.atttypid IN (select oid FROM pg_type WHERE typbasetype=regtype('geometry'))"
") "
"and has_schema_privilege(pg_namespace.nspname,'usage') "
"and has_table_privilege('\"'||pg_namespace.nspname||'\".\"'||pg_class.relname||'\"','select') ";
// user has select privilege
if (searchPublicOnly)
sql += "and pg_namespace.nspname = 'public' ";

sql += "and pg_namespace.nspname||'.'||pg_class.relname not in " // needs to be table and schema
"(select f_table_schema||'.'||f_table_name from geometry_columns) "
"and pg_class.relkind in ('v', 'r')"; // only from views and relations (tables)
sql += "and not exists (select * from geometry_columns WHERE pg_namespace.nspname=f_table_schema AND pg_class.relname=f_table_name) "
"and pg_class.relkind in ('v', 'r')"; // only from views and relations (tables)

result = PQexec(pg, sql.toUtf8());

Expand Down

0 comments on commit 64e827a

Please sign in to comment.