Skip to content
Permalink
Browse files
implement #1087
git-svn-id: http://svn.osgeo.org/qgis/trunk@8444 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed May 15, 2008
1 parent 127b656 commit 22b38021944deb280bf118e856b238458609c418
Showing with 7 additions and 4 deletions.
  1. +7 −4 src/app/qgsdbsourceselect.cpp
@@ -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());

0 comments on commit 22b3802

Please sign in to comment.