github-57.slt 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Regression test for incidents-and-escalations#57.
  10. statement ok
  11. with table_privileges as (
  12. select
  13. NULL as role,
  14. t.schemaname as schema,
  15. t.objectname as table,
  16. pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'UPDATE') as update,
  17. pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'SELECT') as select,
  18. pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'INSERT') as insert,
  19. pg_catalog.has_table_privilege(current_user, '"' || t.schemaname || '"' || '.' || '"' || t.objectname || '"', 'DELETE') as delete
  20. from (
  21. select schemaname, tablename as objectname from pg_catalog.pg_tables
  22. union
  23. select schemaname, viewname as objectname from pg_catalog.pg_views
  24. union
  25. select schemaname, matviewname as objectname from pg_catalog.pg_matviews
  26. ) t
  27. where t.schemaname !~ '^pg_'
  28. and t.schemaname <> 'information_schema'
  29. and pg_catalog.has_schema_privilege(current_user, t.schemaname, 'USAGE')
  30. )
  31. select t.*
  32. from table_privileges t