Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit d1ac2fb

Browse files
committedNov 15, 2019
Simplify calls to has_*_privilege to avoid name resolution
... when oid is already known...
1 parent 5c55c68 commit d1ac2fb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎src/providers/postgres/qgspostgresconn.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
543543
" AND a.attnum>0"
544544
" AND n.oid=c.relnamespace"
545545
" AND has_schema_privilege(n.nspname,'usage')"
546-
" AND has_table_privilege('\"'||n.nspname||'\".\"'||c.relname||'\"','select')" // user has select privilege
546+
" AND has_table_privilege(c.oid,'select')" // user has select privilege
547547
)
548548
.arg( tableName, schemaName, columnName, typeName, sridName, dimName, gtableName )
549549
.arg( 1 )
@@ -662,7 +662,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
662662
//search for geometry columns in tables that are not in the geometry_columns metatable
663663
if ( !searchGeometryColumnsOnly )
664664
{
665-
// Now have a look for geometry columns that aren't in the geometry_columns table.
665+
// Now have a look for spatial columns that aren't in the geometry_columns table.
666666
QString sql = "SELECT"
667667
" c.relname"
668668
",n.nspname"
@@ -677,7 +677,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
677677
" LEFT JOIN pg_type b ON b.oid=t.typbasetype"
678678
" WHERE c.relkind IN ('v','r','m','p')"
679679
" AND has_schema_privilege( n.nspname, 'usage' )"
680-
" AND has_table_privilege( QUOTE_IDENT(n.nspname) || '.' || QUOTE_IDENT(c.relname), 'select' )"
680+
" AND has_table_privilege( c.oid, 'select' )"
681681
" AND (t.typname IN ('geometry','geography','topogeometry') OR b.typname IN ('geometry','geography','topogeometry','pcpatch','raster'))";
682682

683683
// user has select privilege
@@ -806,7 +806,7 @@ bool QgsPostgresConn::getTableInfo( bool searchGeometryColumnsOnly, bool searchP
806806
",pg_attribute a"
807807
" WHERE pg_namespace.oid=pg_class.relnamespace"
808808
" AND has_schema_privilege(pg_namespace.nspname,'usage')"
809-
" AND has_table_privilege('\"' || pg_namespace.nspname || '\".\"' || pg_class.relname || '\"','select')"
809+
" AND has_table_privilege(pg_class.oid,'select')"
810810
" AND pg_class.relkind IN ('v','r','m','p')"
811811
" AND pg_class.oid = a.attrelid"
812812
" AND NOT a.attisdropped"

0 commit comments

Comments
 (0)
Please sign in to comment.