Skip to content
Permalink
Browse files

Only consider raster available when metadata table is readable

Closes #32558

Includes automated test.
  • Loading branch information
strk committed Feb 21, 2020
1 parent 8f3a596 commit d15ce6b4c30f9faed8b818c575d6b729192fa064
@@ -1121,8 +1121,16 @@ WHERE c.relnamespace = n.oid
QgsDebugMsg( QStringLiteral( "Checking for raster support" ) );
if ( mPostgisVersionMajor >= 2 )
{
QgsPostgresResult result( PQexec( QStringLiteral( "SELECT oid FROM pg_catalog.pg_type WHERE typname='raster'" ) ) );
if ( result.PQntuples() >= 1 )
result = PQexec( QStringLiteral( R"(
SELECT
has_table_privilege(c.oid, 'select')
FROM pg_class c, pg_namespace n, pg_type t
WHERE c.relnamespace = n.oid
AND n.oid = t.typnamespace
AND c.relname = 'raster_columns'
AND t.typname = 'raster'
)" ), false );
if ( result.PQntuples() >= 1 && result.PQgetvalue( 0, 0 ) == QLatin1String( "t" ) )
{
mRasterAvailable = true;
QgsDebugMsg( QStringLiteral( "Raster support available!" ) );
@@ -140,16 +140,22 @@ def test_postgis_connections(self):
# Revoke select permissions on pointcloud_format from qgis_test_user
conn.executeSql('REVOKE SELECT ON pointcloud_formats FROM qgis_test_user')

# Revoke select permissions on pointcloud_format from qgis_test_user
conn.executeSql('REVOKE SELECT ON raster_columns FROM public')
conn.executeSql('REVOKE SELECT ON raster_columns FROM qgis_test_user')

# Re-connect as the qgis_test_role role
newuri = self.uri + ' user=qgis_test_user password=qgis_test_user_password'
newconn = md.createConnection(newuri, {})

# Check TopoGeometry and Pointcloud layers are not found in vector table names
tables = newconn.tables('qgis_test', QgsAbstractDatabaseProviderConnection.Vector)
tableTypes = QgsAbstractDatabaseProviderConnection.Vector | QgsAbstractDatabaseProviderConnection.Raster
tables = newconn.tables('qgis_test', tableTypes)
table_names = self._table_names(tables)
self.assertFalse('TopoLayer1' in table_names)
self.assertFalse('PointCloudPointLayer' in table_names)
self.assertFalse('PointCloudPatchLayer' in table_names)
self.assertFalse('Raster1' in table_names)
self.assertTrue('geometries_table' in table_names)

# TODO: only revoke select permission on topology.layer, grant
@@ -166,8 +172,14 @@ def test_postgis_connections(self):

# Grant select permissions back on topology.topology to qgis_test_user
conn.executeSql('GRANT SELECT ON topology.topology TO qgis_test_user')

# Grant select permissions back on pointcloud_formats to qgis_test_user
conn.executeSql('GRANT SELECT ON pointcloud_formats TO qgis_test_user')

# Grant select permissions back on raster_columns to qgis_test_user
conn.executeSql('GRANT SELECT ON raster_columns TO public')
conn.executeSql('GRANT SELECT ON raster_columns TO qgis_test_user')

# error: ERROR: relation "qgis_test.raster1" does not exist
@unittest.skipIf(gdal.VersionInfo() < '2040000', 'This test requires GDAL >= 2.4.0')
def test_postgis_raster_rename(self):

0 comments on commit d15ce6b

Please sign in to comment.
You can’t perform that action at this time.