# LogicTest: local

statement ok
CREATE DATABASE a

statement ok
CREATE USER readwrite

statement ok
GRANT ALL ON DATABASE a TO readwrite

query TTTB colnames,rowsort
SHOW GRANTS ON DATABASE a
----
database_name  grantee    privilege_type  is_grantable
a              admin      ALL             true
a              public     CONNECT         false
a              readwrite  ALL             false
a              root       ALL             true

# Show that by default GRANT is restricted to the current database, but be sure
# to filter the built-in internal vtables down to just one so that we are not
# enumerating all builtins and being overly broad and brittle.
query TTTTTTB colnames,rowsort
WITH grants AS (SHOW GRANTS) SELECT * FROM grants WHERE 
  (schema_name <> 'crdb_internal' OR object_name = 'session_variables')
----
database_name  schema_name         object_name                            object_type  grantee  privilege_type  is_grantable
test           public              NULL                                   schema       admin    ALL             true
test           pg_catalog          unknown                                type         admin    ALL             false
test           pg_catalog          regclass                               type         admin    ALL             false
test           pg_catalog          bpchar[]                               type         admin    ALL             false
test           pg_catalog          regtype[]                              type         admin    ALL             false
test           pg_catalog          trigger                                type         admin    ALL             false
test           pg_catalog          string                                 type         admin    ALL             false
test           pg_catalog          regnamespace                           type         admin    ALL             false
test           pg_catalog          date                                   type         admin    ALL             false
test           pg_catalog          vector[]                               type         admin    ALL             false
test           pg_catalog          inet[]                                 type         admin    ALL             false
test           pg_catalog          regprocedure                           type         admin    ALL             false
test           pg_catalog          refcursor                              type         admin    ALL             false
test           pg_catalog          record                                 type         admin    ALL             false
test           pg_catalog          int                                    type         admin    ALL             false
test           pg_catalog          "char"                                 type         admin    ALL             false
test           pg_catalog          int4[]                                 type         admin    ALL             false
test           pg_catalog          bool[]                                 type         admin    ALL             false
test           pg_catalog          anyarray                               type         admin    ALL             false
test           pg_catalog          pg_lsn[]                               type         admin    ALL             false
test           pg_catalog          int[]                                  type         admin    ALL             false
test           pg_catalog          regrole                                type         admin    ALL             false
test           pg_catalog          inet                                   type         admin    ALL             false
test           pg_catalog          time[]                                 type         admin    ALL             false
test           pg_catalog          void                                   type         admin    ALL             false
test           pg_catalog          date[]                                 type         admin    ALL             false
test           pg_catalog          box2d[]                                type         admin    ALL             false
test           pg_catalog          int2vector[]                           type         admin    ALL             false
test           pg_catalog          uuid[]                                 type         admin    ALL             false
test           pg_catalog          "char"[]                               type         admin    ALL             false
test           pg_catalog          tsquery                                type         admin    ALL             false
test           pg_catalog          timestamptz                            type         admin    ALL             false
test           pg_catalog          jsonb[]                                type         admin    ALL             false
test           pg_catalog          timestamp[]                            type         admin    ALL             false
test           pg_catalog          regrole[]                              type         admin    ALL             false
test           pg_catalog          regclass[]                             type         admin    ALL             false
test           pg_catalog          decimal[]                              type         admin    ALL             false
test           pg_catalog          geometry                               type         admin    ALL             false
test           pg_catalog          regproc                                type         admin    ALL             false
test           pg_catalog          jsonb                                  type         admin    ALL             false
test           pg_catalog          timetz[]                               type         admin    ALL             false
test           pg_catalog          varbit[]                               type         admin    ALL             false
test           pg_catalog          int2[]                                 type         admin    ALL             false
test           pg_catalog          uuid                                   type         admin    ALL             false
test           pg_catalog          bytes                                  type         admin    ALL             false
test           pg_catalog          regprocedure[]                         type         admin    ALL             false
test           pg_catalog          int2                                   type         admin    ALL             false
test           pg_catalog          float4                                 type         admin    ALL             false
test           pg_catalog          interval[]                             type         admin    ALL             false
test           pg_catalog          box2d                                  type         admin    ALL             false
test           pg_catalog          regtype                                type         admin    ALL             false
test           pg_catalog          pg_lsn                                 type         admin    ALL             false
test           pg_catalog          decimal                                type         admin    ALL             false
test           pg_catalog          interval                               type         admin    ALL             false
test           pg_catalog          bool                                   type         admin    ALL             false
test           pg_catalog          bit                                    type         admin    ALL             false
test           pg_catalog          record[]                               type         admin    ALL             false
test           pg_catalog          oidvector[]                            type         admin    ALL             false
test           pg_catalog          float4[]                               type         admin    ALL             false
test           pg_catalog          bit[]                                  type         admin    ALL             false
test           pg_catalog          bytes[]                                type         admin    ALL             false
test           pg_catalog          name[]                                 type         admin    ALL             false
test           pg_catalog          vector                                 type         admin    ALL             false
test           pg_catalog          regproc[]                              type         admin    ALL             false
test           pg_catalog          float[]                                type         admin    ALL             false
test           pg_catalog          timestamp                              type         admin    ALL             false
test           pg_catalog          int4                                   type         admin    ALL             false
test           pg_catalog          geometry[]                             type         admin    ALL             false
test           pg_catalog          refcursor[]                            type         admin    ALL             false
test           pg_catalog          oid[]                                  type         admin    ALL             false
test           pg_catalog          timestamptz[]                          type         admin    ALL             false
test           pg_catalog          varbit                                 type         admin    ALL             false
test           pg_catalog          oidvector                              type         admin    ALL             false
test           pg_catalog          oid                                    type         admin    ALL             false
test           pg_catalog          int2vector                             type         admin    ALL             false
test           pg_catalog          bpchar                                 type         admin    ALL             false
test           pg_catalog          anyelement                             type         admin    ALL             false
test           pg_catalog          regnamespace[]                         type         admin    ALL             false
test           pg_catalog          tsvector[]                             type         admin    ALL             false
test           pg_catalog          varchar[]                              type         admin    ALL             false
test           pg_catalog          geography[]                            type         admin    ALL             false
test           pg_catalog          geography                              type         admin    ALL             false
test           pg_catalog          time                                   type         admin    ALL             false
test           pg_catalog          tsquery[]                              type         admin    ALL             false
test           pg_catalog          string[]                               type         admin    ALL             false
test           pg_catalog          varchar                                type         admin    ALL             false
test           pg_catalog          tsvector                               type         admin    ALL             false
test           pg_catalog          timetz                                 type         admin    ALL             false
test           pg_catalog          name                                   type         admin    ALL             false
test           pg_catalog          float                                  type         admin    ALL             false
test           crdb_internal       session_variables                      table        public   SELECT          false
test           information_schema  administrable_role_authorizations      table        public   SELECT          false
test           information_schema  applicable_roles                       table        public   SELECT          false
test           information_schema  attributes                             table        public   SELECT          false
test           information_schema  character_sets                         table        public   SELECT          false
test           information_schema  check_constraint_routine_usage         table        public   SELECT          false
test           information_schema  check_constraints                      table        public   SELECT          false
test           information_schema  collation_character_set_applicability  table        public   SELECT          false
test           information_schema  collations                             table        public   SELECT          false
test           information_schema  column_column_usage                    table        public   SELECT          false
test           information_schema  column_domain_usage                    table        public   SELECT          false
test           information_schema  column_options                         table        public   SELECT          false
test           information_schema  column_privileges                      table        public   SELECT          false
test           information_schema  column_statistics                      table        public   SELECT          false
test           information_schema  column_udt_usage                       table        public   SELECT          false
test           information_schema  columns                                table        public   SELECT          false
test           information_schema  columns_extensions                     table        public   SELECT          false
test           information_schema  constraint_column_usage                table        public   SELECT          false
test           information_schema  constraint_table_usage                 table        public   SELECT          false
test           information_schema  data_type_privileges                   table        public   SELECT          false
test           information_schema  domain_constraints                     table        public   SELECT          false
test           information_schema  domain_udt_usage                       table        public   SELECT          false
test           information_schema  domains                                table        public   SELECT          false
test           information_schema  element_types                          table        public   SELECT          false
test           information_schema  enabled_roles                          table        public   SELECT          false
test           information_schema  engines                                table        public   SELECT          false
test           information_schema  events                                 table        public   SELECT          false
test           information_schema  files                                  table        public   SELECT          false
test           information_schema  foreign_data_wrapper_options           table        public   SELECT          false
test           information_schema  foreign_data_wrappers                  table        public   SELECT          false
test           information_schema  foreign_server_options                 table        public   SELECT          false
test           information_schema  foreign_servers                        table        public   SELECT          false
test           information_schema  foreign_table_options                  table        public   SELECT          false
test           information_schema  foreign_tables                         table        public   SELECT          false
test           information_schema  information_schema_catalog_name        table        public   SELECT          false
test           information_schema  key_column_usage                       table        public   SELECT          false
test           information_schema  keywords                               table        public   SELECT          false
test           information_schema  optimizer_trace                        table        public   SELECT          false
test           information_schema  parameters                             table        public   SELECT          false
test           information_schema  partitions                             table        public   SELECT          false
test           information_schema  plugins                                table        public   SELECT          false
test           information_schema  processlist                            table        public   SELECT          false
test           information_schema  profiling                              table        public   SELECT          false
test           information_schema  referential_constraints                table        public   SELECT          false
test           information_schema  resource_groups                        table        public   SELECT          false
test           information_schema  role_column_grants                     table        public   SELECT          false
test           information_schema  role_routine_grants                    table        public   SELECT          false
test           information_schema  role_table_grants                      table        public   SELECT          false
test           information_schema  role_udt_grants                        table        public   SELECT          false
test           information_schema  role_usage_grants                      table        public   SELECT          false
test           information_schema  routine_privileges                     table        public   SELECT          false
test           information_schema  routines                               table        public   SELECT          false
test           information_schema  schema_privileges                      table        public   SELECT          false
test           information_schema  schemata                               table        public   SELECT          false
test           information_schema  schemata_extensions                    table        public   SELECT          false
test           information_schema  sequences                              table        public   SELECT          false
test           information_schema  session_variables                      table        public   SELECT          false
test           information_schema  sql_features                           table        public   SELECT          false
test           information_schema  sql_implementation_info                table        public   SELECT          false
test           information_schema  sql_parts                              table        public   SELECT          false
test           information_schema  sql_sizing                             table        public   SELECT          false
test           information_schema  st_geometry_columns                    table        public   SELECT          false
test           information_schema  st_spatial_reference_systems           table        public   SELECT          false
test           information_schema  st_units_of_measure                    table        public   SELECT          false
test           information_schema  statistics                             table        public   SELECT          false
test           information_schema  table_constraints                      table        public   SELECT          false
test           information_schema  table_constraints_extensions           table        public   SELECT          false
test           information_schema  table_privileges                       table        public   SELECT          false
test           information_schema  tables                                 table        public   SELECT          false
test           information_schema  tables_extensions                      table        public   SELECT          false
test           information_schema  tablespaces                            table        public   SELECT          false
test           information_schema  tablespaces_extensions                 table        public   SELECT          false
test           information_schema  transforms                             table        public   SELECT          false
test           information_schema  triggered_update_columns               table        public   SELECT          false
test           information_schema  triggers                               table        public   SELECT          false
test           information_schema  type_privileges                        table        public   SELECT          false
test           information_schema  udt_privileges                         table        public   SELECT          false
test           information_schema  usage_privileges                       table        public   SELECT          false
test           information_schema  user_attributes                        table        public   SELECT          false
test           information_schema  user_defined_types                     table        public   SELECT          false
test           information_schema  user_mapping_options                   table        public   SELECT          false
test           information_schema  user_mappings                          table        public   SELECT          false
test           information_schema  user_privileges                        table        public   SELECT          false
test           information_schema  view_column_usage                      table        public   SELECT          false
test           information_schema  view_routine_usage                     table        public   SELECT          false
test           information_schema  view_table_usage                       table        public   SELECT          false
test           information_schema  views                                  table        public   SELECT          false
test           pg_catalog          pg_aggregate                           table        public   SELECT          false
test           pg_catalog          pg_am                                  table        public   SELECT          false
test           pg_catalog          pg_amop                                table        public   SELECT          false
test           pg_catalog          pg_amproc                              table        public   SELECT          false
test           pg_catalog          pg_attrdef                             table        public   SELECT          false
test           pg_catalog          pg_attribute                           table        public   SELECT          false
test           pg_catalog          pg_auth_members                        table        public   SELECT          false
test           pg_catalog          pg_authid                              table        public   SELECT          false
test           pg_catalog          pg_available_extension_versions        table        public   SELECT          false
test           pg_catalog          pg_available_extensions                table        public   SELECT          false
test           pg_catalog          pg_cast                                table        public   SELECT          false
test           pg_catalog          pg_class                               table        public   SELECT          false
test           pg_catalog          pg_collation                           table        public   SELECT          false
test           pg_catalog          pg_config                              table        public   SELECT          false
test           pg_catalog          pg_constraint                          table        public   SELECT          false
test           pg_catalog          pg_conversion                          table        public   SELECT          false
test           pg_catalog          pg_cursors                             table        public   SELECT          false
test           pg_catalog          pg_database                            table        public   SELECT          false
test           pg_catalog          pg_db_role_setting                     table        public   SELECT          false
test           pg_catalog          pg_default_acl                         table        public   SELECT          false
test           pg_catalog          pg_depend                              table        public   SELECT          false
test           pg_catalog          pg_description                         table        public   SELECT          false
test           pg_catalog          pg_enum                                table        public   SELECT          false
test           pg_catalog          pg_event_trigger                       table        public   SELECT          false
test           pg_catalog          pg_extension                           table        public   SELECT          false
test           pg_catalog          pg_file_settings                       table        public   SELECT          false
test           pg_catalog          pg_foreign_data_wrapper                table        public   SELECT          false
test           pg_catalog          pg_foreign_server                      table        public   SELECT          false
test           pg_catalog          pg_foreign_table                       table        public   SELECT          false
test           pg_catalog          pg_group                               table        public   SELECT          false
test           pg_catalog          pg_hba_file_rules                      table        public   SELECT          false
test           pg_catalog          pg_index                               table        public   SELECT          false
test           pg_catalog          pg_indexes                             table        public   SELECT          false
test           pg_catalog          pg_inherits                            table        public   SELECT          false
test           pg_catalog          pg_init_privs                          table        public   SELECT          false
test           pg_catalog          pg_language                            table        public   SELECT          false
test           pg_catalog          pg_largeobject                         table        public   SELECT          false
test           pg_catalog          pg_largeobject_metadata                table        public   SELECT          false
test           pg_catalog          pg_locks                               table        public   SELECT          false
test           pg_catalog          pg_matviews                            table        public   SELECT          false
test           pg_catalog          pg_namespace                           table        public   SELECT          false
test           pg_catalog          pg_opclass                             table        public   SELECT          false
test           pg_catalog          pg_operator                            table        public   SELECT          false
test           pg_catalog          pg_opfamily                            table        public   SELECT          false
test           pg_catalog          pg_partitioned_table                   table        public   SELECT          false
test           pg_catalog          pg_policies                            table        public   SELECT          false
test           pg_catalog          pg_policy                              table        public   SELECT          false
test           pg_catalog          pg_prepared_statements                 table        public   SELECT          false
test           pg_catalog          pg_prepared_xacts                      table        public   SELECT          false
test           pg_catalog          pg_proc                                table        public   SELECT          false
test           pg_catalog          pg_publication                         table        public   SELECT          false
test           pg_catalog          pg_publication_rel                     table        public   SELECT          false
test           pg_catalog          pg_publication_tables                  table        public   SELECT          false
test           pg_catalog          pg_range                               table        public   SELECT          false
test           pg_catalog          pg_replication_origin                  table        public   SELECT          false
test           pg_catalog          pg_replication_origin_status           table        public   SELECT          false
test           pg_catalog          pg_replication_slots                   table        public   SELECT          false
test           pg_catalog          pg_rewrite                             table        public   SELECT          false
test           pg_catalog          pg_roles                               table        public   SELECT          false
test           pg_catalog          pg_rules                               table        public   SELECT          false
test           pg_catalog          pg_seclabel                            table        public   SELECT          false
test           pg_catalog          pg_seclabels                           table        public   SELECT          false
test           pg_catalog          pg_sequence                            table        public   SELECT          false
test           pg_catalog          pg_sequences                           table        public   SELECT          false
test           pg_catalog          pg_settings                            table        public   SELECT          false
test           pg_catalog          pg_shadow                              table        public   SELECT          false
test           pg_catalog          pg_shdepend                            table        public   SELECT          false
test           pg_catalog          pg_shdescription                       table        public   SELECT          false
test           pg_catalog          pg_shmem_allocations                   table        public   SELECT          false
test           pg_catalog          pg_shseclabel                          table        public   SELECT          false
test           pg_catalog          pg_stat_activity                       table        public   SELECT          false
test           pg_catalog          pg_stat_all_indexes                    table        public   SELECT          false
test           pg_catalog          pg_stat_all_tables                     table        public   SELECT          false
test           pg_catalog          pg_stat_archiver                       table        public   SELECT          false
test           pg_catalog          pg_stat_bgwriter                       table        public   SELECT          false
test           pg_catalog          pg_stat_database                       table        public   SELECT          false
test           pg_catalog          pg_stat_database_conflicts             table        public   SELECT          false
test           pg_catalog          pg_stat_gssapi                         table        public   SELECT          false
test           pg_catalog          pg_stat_progress_analyze               table        public   SELECT          false
test           pg_catalog          pg_stat_progress_basebackup            table        public   SELECT          false
test           pg_catalog          pg_stat_progress_cluster               table        public   SELECT          false
test           pg_catalog          pg_stat_progress_create_index          table        public   SELECT          false
test           pg_catalog          pg_stat_progress_vacuum                table        public   SELECT          false
test           pg_catalog          pg_stat_replication                    table        public   SELECT          false
test           pg_catalog          pg_stat_slru                           table        public   SELECT          false
test           pg_catalog          pg_stat_ssl                            table        public   SELECT          false
test           pg_catalog          pg_stat_subscription                   table        public   SELECT          false
test           pg_catalog          pg_stat_sys_indexes                    table        public   SELECT          false
test           pg_catalog          pg_stat_sys_tables                     table        public   SELECT          false
test           pg_catalog          pg_stat_user_functions                 table        public   SELECT          false
test           pg_catalog          pg_stat_user_indexes                   table        public   SELECT          false
test           pg_catalog          pg_stat_user_tables                    table        public   SELECT          false
test           pg_catalog          pg_stat_wal_receiver                   table        public   SELECT          false
test           pg_catalog          pg_stat_xact_all_tables                table        public   SELECT          false
test           pg_catalog          pg_stat_xact_sys_tables                table        public   SELECT          false
test           pg_catalog          pg_stat_xact_user_functions            table        public   SELECT          false
test           pg_catalog          pg_stat_xact_user_tables               table        public   SELECT          false
test           pg_catalog          pg_statio_all_indexes                  table        public   SELECT          false
test           pg_catalog          pg_statio_all_sequences                table        public   SELECT          false
test           pg_catalog          pg_statio_all_tables                   table        public   SELECT          false
test           pg_catalog          pg_statio_sys_indexes                  table        public   SELECT          false
test           pg_catalog          pg_statio_sys_sequences                table        public   SELECT          false
test           pg_catalog          pg_statio_sys_tables                   table        public   SELECT          false
test           pg_catalog          pg_statio_user_indexes                 table        public   SELECT          false
test           pg_catalog          pg_statio_user_sequences               table        public   SELECT          false
test           pg_catalog          pg_statio_user_tables                  table        public   SELECT          false
test           pg_catalog          pg_statistic                           table        public   SELECT          false
test           pg_catalog          pg_statistic_ext                       table        public   SELECT          false
test           pg_catalog          pg_statistic_ext_data                  table        public   SELECT          false
test           pg_catalog          pg_stats                               table        public   SELECT          false
test           pg_catalog          pg_stats_ext                           table        public   SELECT          false
test           pg_catalog          pg_subscription                        table        public   SELECT          false
test           pg_catalog          pg_subscription_rel                    table        public   SELECT          false
test           pg_catalog          pg_tables                              table        public   SELECT          false
test           pg_catalog          pg_tablespace                          table        public   SELECT          false
test           pg_catalog          pg_timezone_abbrevs                    table        public   SELECT          false
test           pg_catalog          pg_timezone_names                      table        public   SELECT          false
test           pg_catalog          pg_transform                           table        public   SELECT          false
test           pg_catalog          pg_trigger                             table        public   SELECT          false
test           pg_catalog          pg_ts_config                           table        public   SELECT          false
test           pg_catalog          pg_ts_config_map                       table        public   SELECT          false
test           pg_catalog          pg_ts_dict                             table        public   SELECT          false
test           pg_catalog          pg_ts_parser                           table        public   SELECT          false
test           pg_catalog          pg_ts_template                         table        public   SELECT          false
test           pg_catalog          pg_type                                table        public   SELECT          false
test           pg_catalog          pg_user                                table        public   SELECT          false
test           pg_catalog          pg_user_mapping                        table        public   SELECT          false
test           pg_catalog          pg_user_mappings                       table        public   SELECT          false
test           pg_catalog          pg_views                               table        public   SELECT          false
test           pg_extension        geography_columns                      table        public   SELECT          false
test           pg_extension        geometry_columns                       table        public   SELECT          false
test           pg_extension        spatial_ref_sys                        table        public   SELECT          false
test           information_schema  NULL                                   schema       public   USAGE           false
test           pg_catalog          NULL                                   schema       public   USAGE           false
test           pg_extension        NULL                                   schema       public   USAGE           false
test           public              NULL                                   schema       public   CREATE          false
test           public              NULL                                   schema       public   USAGE           false
test           public              NULL                                   schema       root     ALL             true
test           pg_catalog          float                                  type         root     ALL             false
test           pg_catalog          float                                  type         public   USAGE           false
test           pg_catalog          name                                   type         root     ALL             false
test           pg_catalog          name                                   type         public   USAGE           false
test           pg_catalog          timetz                                 type         root     ALL             false
test           pg_catalog          timetz                                 type         public   USAGE           false
test           pg_catalog          tsvector                               type         root     ALL             false
test           pg_catalog          tsvector                               type         public   USAGE           false
test           pg_catalog          varchar                                type         root     ALL             false
test           pg_catalog          varchar                                type         public   USAGE           false
test           pg_catalog          string[]                               type         root     ALL             false
test           pg_catalog          string[]                               type         public   USAGE           false
test           pg_catalog          tsquery[]                              type         root     ALL             false
test           pg_catalog          tsquery[]                              type         public   USAGE           false
test           pg_catalog          time                                   type         root     ALL             false
test           pg_catalog          time                                   type         public   USAGE           false
test           pg_catalog          geography                              type         root     ALL             false
test           pg_catalog          geography                              type         public   USAGE           false
test           pg_catalog          geography[]                            type         root     ALL             false
test           pg_catalog          geography[]                            type         public   USAGE           false
test           pg_catalog          varchar[]                              type         root     ALL             false
test           pg_catalog          varchar[]                              type         public   USAGE           false
test           pg_catalog          tsvector[]                             type         root     ALL             false
test           pg_catalog          tsvector[]                             type         public   USAGE           false
test           pg_catalog          regnamespace[]                         type         root     ALL             false
test           pg_catalog          regnamespace[]                         type         public   USAGE           false
test           pg_catalog          anyelement                             type         root     ALL             false
test           pg_catalog          anyelement                             type         public   USAGE           false
test           pg_catalog          bpchar                                 type         root     ALL             false
test           pg_catalog          bpchar                                 type         public   USAGE           false
test           pg_catalog          int2vector                             type         root     ALL             false
test           pg_catalog          int2vector                             type         public   USAGE           false
test           pg_catalog          oid                                    type         root     ALL             false
test           pg_catalog          oid                                    type         public   USAGE           false
test           pg_catalog          oidvector                              type         root     ALL             false
test           pg_catalog          oidvector                              type         public   USAGE           false
test           pg_catalog          varbit                                 type         root     ALL             false
test           pg_catalog          varbit                                 type         public   USAGE           false
test           pg_catalog          timestamptz[]                          type         root     ALL             false
test           pg_catalog          timestamptz[]                          type         public   USAGE           false
test           pg_catalog          oid[]                                  type         root     ALL             false
test           pg_catalog          oid[]                                  type         public   USAGE           false
test           pg_catalog          refcursor[]                            type         root     ALL             false
test           pg_catalog          refcursor[]                            type         public   USAGE           false
test           pg_catalog          geometry[]                             type         root     ALL             false
test           pg_catalog          geometry[]                             type         public   USAGE           false
test           pg_catalog          int4                                   type         root     ALL             false
test           pg_catalog          int4                                   type         public   USAGE           false
test           pg_catalog          timestamp                              type         root     ALL             false
test           pg_catalog          timestamp                              type         public   USAGE           false
test           pg_catalog          float[]                                type         root     ALL             false
test           pg_catalog          float[]                                type         public   USAGE           false
test           pg_catalog          regproc[]                              type         root     ALL             false
test           pg_catalog          regproc[]                              type         public   USAGE           false
test           pg_catalog          vector                                 type         root     ALL             false
test           pg_catalog          vector                                 type         public   USAGE           false
test           pg_catalog          name[]                                 type         root     ALL             false
test           pg_catalog          name[]                                 type         public   USAGE           false
test           pg_catalog          bytes[]                                type         root     ALL             false
test           pg_catalog          bytes[]                                type         public   USAGE           false
test           pg_catalog          bit[]                                  type         root     ALL             false
test           pg_catalog          bit[]                                  type         public   USAGE           false
test           pg_catalog          float4[]                               type         root     ALL             false
test           pg_catalog          float4[]                               type         public   USAGE           false
test           pg_catalog          oidvector[]                            type         root     ALL             false
test           pg_catalog          oidvector[]                            type         public   USAGE           false
test           pg_catalog          record[]                               type         root     ALL             false
test           pg_catalog          record[]                               type         public   USAGE           false
test           pg_catalog          bit                                    type         root     ALL             false
test           pg_catalog          bit                                    type         public   USAGE           false
test           pg_catalog          bool                                   type         root     ALL             false
test           pg_catalog          bool                                   type         public   USAGE           false
test           pg_catalog          interval                               type         root     ALL             false
test           pg_catalog          interval                               type         public   USAGE           false
test           pg_catalog          decimal                                type         root     ALL             false
test           pg_catalog          decimal                                type         public   USAGE           false
test           pg_catalog          pg_lsn                                 type         root     ALL             false
test           pg_catalog          pg_lsn                                 type         public   USAGE           false
test           pg_catalog          regtype                                type         root     ALL             false
test           pg_catalog          regtype                                type         public   USAGE           false
test           pg_catalog          box2d                                  type         root     ALL             false
test           pg_catalog          box2d                                  type         public   USAGE           false
test           pg_catalog          interval[]                             type         root     ALL             false
test           pg_catalog          interval[]                             type         public   USAGE           false
test           pg_catalog          float4                                 type         root     ALL             false
test           pg_catalog          float4                                 type         public   USAGE           false
test           pg_catalog          int2                                   type         root     ALL             false
test           pg_catalog          int2                                   type         public   USAGE           false
test           pg_catalog          regprocedure[]                         type         root     ALL             false
test           pg_catalog          regprocedure[]                         type         public   USAGE           false
test           pg_catalog          bytes                                  type         root     ALL             false
test           pg_catalog          bytes                                  type         public   USAGE           false
test           pg_catalog          uuid                                   type         root     ALL             false
test           pg_catalog          uuid                                   type         public   USAGE           false
test           pg_catalog          int2[]                                 type         root     ALL             false
test           pg_catalog          int2[]                                 type         public   USAGE           false
test           pg_catalog          varbit[]                               type         root     ALL             false
test           pg_catalog          varbit[]                               type         public   USAGE           false
test           pg_catalog          timetz[]                               type         root     ALL             false
test           pg_catalog          timetz[]                               type         public   USAGE           false
test           pg_catalog          jsonb                                  type         root     ALL             false
test           pg_catalog          jsonb                                  type         public   USAGE           false
test           pg_catalog          regproc                                type         root     ALL             false
test           pg_catalog          regproc                                type         public   USAGE           false
test           pg_catalog          geometry                               type         root     ALL             false
test           pg_catalog          geometry                               type         public   USAGE           false
test           pg_catalog          decimal[]                              type         root     ALL             false
test           pg_catalog          decimal[]                              type         public   USAGE           false
test           pg_catalog          regclass[]                             type         root     ALL             false
test           pg_catalog          regclass[]                             type         public   USAGE           false
test           pg_catalog          regrole[]                              type         root     ALL             false
test           pg_catalog          regrole[]                              type         public   USAGE           false
test           pg_catalog          timestamp[]                            type         root     ALL             false
test           pg_catalog          timestamp[]                            type         public   USAGE           false
test           pg_catalog          jsonb[]                                type         root     ALL             false
test           pg_catalog          jsonb[]                                type         public   USAGE           false
test           pg_catalog          timestamptz                            type         root     ALL             false
test           pg_catalog          timestamptz                            type         public   USAGE           false
test           pg_catalog          tsquery                                type         root     ALL             false
test           pg_catalog          tsquery                                type         public   USAGE           false
test           pg_catalog          "char"[]                               type         root     ALL             false
test           pg_catalog          "char"[]                               type         public   USAGE           false
test           pg_catalog          uuid[]                                 type         root     ALL             false
test           pg_catalog          uuid[]                                 type         public   USAGE           false
test           pg_catalog          int2vector[]                           type         root     ALL             false
test           pg_catalog          int2vector[]                           type         public   USAGE           false
test           pg_catalog          box2d[]                                type         root     ALL             false
test           pg_catalog          box2d[]                                type         public   USAGE           false
test           pg_catalog          date[]                                 type         root     ALL             false
test           pg_catalog          date[]                                 type         public   USAGE           false
test           pg_catalog          void                                   type         root     ALL             false
test           pg_catalog          void                                   type         public   USAGE           false
test           pg_catalog          time[]                                 type         root     ALL             false
test           pg_catalog          time[]                                 type         public   USAGE           false
test           pg_catalog          inet                                   type         root     ALL             false
test           pg_catalog          inet                                   type         public   USAGE           false
test           pg_catalog          regrole                                type         root     ALL             false
test           pg_catalog          regrole                                type         public   USAGE           false
test           pg_catalog          int[]                                  type         root     ALL             false
test           pg_catalog          int[]                                  type         public   USAGE           false
test           pg_catalog          pg_lsn[]                               type         root     ALL             false
test           pg_catalog          pg_lsn[]                               type         public   USAGE           false
test           pg_catalog          anyarray                               type         root     ALL             false
test           pg_catalog          anyarray                               type         public   USAGE           false
test           pg_catalog          bool[]                                 type         root     ALL             false
test           pg_catalog          bool[]                                 type         public   USAGE           false
test           pg_catalog          int4[]                                 type         root     ALL             false
test           pg_catalog          int4[]                                 type         public   USAGE           false
test           pg_catalog          "char"                                 type         root     ALL             false
test           pg_catalog          "char"                                 type         public   USAGE           false
test           pg_catalog          int                                    type         root     ALL             false
test           pg_catalog          int                                    type         public   USAGE           false
test           pg_catalog          record                                 type         root     ALL             false
test           pg_catalog          record                                 type         public   USAGE           false
test           pg_catalog          refcursor                              type         root     ALL             false
test           pg_catalog          refcursor                              type         public   USAGE           false
test           pg_catalog          regprocedure                           type         root     ALL             false
test           pg_catalog          regprocedure                           type         public   USAGE           false
test           pg_catalog          inet[]                                 type         root     ALL             false
test           pg_catalog          inet[]                                 type         public   USAGE           false
test           pg_catalog          vector[]                               type         root     ALL             false
test           pg_catalog          vector[]                               type         public   USAGE           false
test           pg_catalog          date                                   type         root     ALL             false
test           pg_catalog          date                                   type         public   USAGE           false
test           pg_catalog          regnamespace                           type         root     ALL             false
test           pg_catalog          regnamespace                           type         public   USAGE           false
test           pg_catalog          string                                 type         root     ALL             false
test           pg_catalog          string                                 type         public   USAGE           false
test           pg_catalog          trigger                                type         root     ALL             false
test           pg_catalog          trigger                                type         public   USAGE           false
test           pg_catalog          regtype[]                              type         root     ALL             false
test           pg_catalog          regtype[]                              type         public   USAGE           false
test           pg_catalog          bpchar[]                               type         root     ALL             false
test           pg_catalog          bpchar[]                               type         public   USAGE           false
test           pg_catalog          regclass                               type         root     ALL             false
test           pg_catalog          regclass                               type         public   USAGE           false
test           pg_catalog          unknown                                type         root     ALL             false
test           pg_catalog          unknown                                type         public   USAGE           false

query TTTTTTB colnames,rowsort
SHOW GRANTS FOR root
----
database_name  schema_name  object_name     object_type  grantee  privilege_type  is_grantable
test           NULL         NULL            database     admin    ALL             true
test           NULL         NULL            database     root     ALL             true
test           pg_catalog   "char"          type         admin    ALL             false
test           pg_catalog   "char"          type         root     ALL             false
test           pg_catalog   "char"[]        type         admin    ALL             false
test           pg_catalog   "char"[]        type         root     ALL             false
test           pg_catalog   anyarray        type         admin    ALL             false
test           pg_catalog   anyarray        type         root     ALL             false
test           pg_catalog   anyelement      type         admin    ALL             false
test           pg_catalog   anyelement      type         root     ALL             false
test           pg_catalog   bit             type         admin    ALL             false
test           pg_catalog   bit             type         root     ALL             false
test           pg_catalog   bit[]           type         admin    ALL             false
test           pg_catalog   bit[]           type         root     ALL             false
test           pg_catalog   bool            type         admin    ALL             false
test           pg_catalog   bool            type         root     ALL             false
test           pg_catalog   bool[]          type         admin    ALL             false
test           pg_catalog   bool[]          type         root     ALL             false
test           pg_catalog   box2d           type         admin    ALL             false
test           pg_catalog   box2d           type         root     ALL             false
test           pg_catalog   box2d[]         type         admin    ALL             false
test           pg_catalog   box2d[]         type         root     ALL             false
test           pg_catalog   bpchar          type         admin    ALL             false
test           pg_catalog   bpchar          type         root     ALL             false
test           pg_catalog   bpchar[]        type         admin    ALL             false
test           pg_catalog   bpchar[]        type         root     ALL             false
test           pg_catalog   bytes           type         admin    ALL             false
test           pg_catalog   bytes           type         root     ALL             false
test           pg_catalog   bytes[]         type         admin    ALL             false
test           pg_catalog   bytes[]         type         root     ALL             false
test           pg_catalog   date            type         admin    ALL             false
test           pg_catalog   date            type         root     ALL             false
test           pg_catalog   date[]          type         admin    ALL             false
test           pg_catalog   date[]          type         root     ALL             false
test           pg_catalog   decimal         type         admin    ALL             false
test           pg_catalog   decimal         type         root     ALL             false
test           pg_catalog   decimal[]       type         admin    ALL             false
test           pg_catalog   decimal[]       type         root     ALL             false
test           pg_catalog   float           type         admin    ALL             false
test           pg_catalog   float           type         root     ALL             false
test           pg_catalog   float4          type         admin    ALL             false
test           pg_catalog   float4          type         root     ALL             false
test           pg_catalog   float4[]        type         admin    ALL             false
test           pg_catalog   float4[]        type         root     ALL             false
test           pg_catalog   float[]         type         admin    ALL             false
test           pg_catalog   float[]         type         root     ALL             false
test           pg_catalog   geography       type         admin    ALL             false
test           pg_catalog   geography       type         root     ALL             false
test           pg_catalog   geography[]     type         admin    ALL             false
test           pg_catalog   geography[]     type         root     ALL             false
test           pg_catalog   geometry        type         admin    ALL             false
test           pg_catalog   geometry        type         root     ALL             false
test           pg_catalog   geometry[]      type         admin    ALL             false
test           pg_catalog   geometry[]      type         root     ALL             false
test           pg_catalog   inet            type         admin    ALL             false
test           pg_catalog   inet            type         root     ALL             false
test           pg_catalog   inet[]          type         admin    ALL             false
test           pg_catalog   inet[]          type         root     ALL             false
test           pg_catalog   int             type         admin    ALL             false
test           pg_catalog   int             type         root     ALL             false
test           pg_catalog   int2            type         admin    ALL             false
test           pg_catalog   int2            type         root     ALL             false
test           pg_catalog   int2[]          type         admin    ALL             false
test           pg_catalog   int2[]          type         root     ALL             false
test           pg_catalog   int2vector      type         admin    ALL             false
test           pg_catalog   int2vector      type         root     ALL             false
test           pg_catalog   int2vector[]    type         admin    ALL             false
test           pg_catalog   int2vector[]    type         root     ALL             false
test           pg_catalog   int4            type         admin    ALL             false
test           pg_catalog   int4            type         root     ALL             false
test           pg_catalog   int4[]          type         admin    ALL             false
test           pg_catalog   int4[]          type         root     ALL             false
test           pg_catalog   int[]           type         admin    ALL             false
test           pg_catalog   int[]           type         root     ALL             false
test           pg_catalog   interval        type         admin    ALL             false
test           pg_catalog   interval        type         root     ALL             false
test           pg_catalog   interval[]      type         admin    ALL             false
test           pg_catalog   interval[]      type         root     ALL             false
test           pg_catalog   jsonb           type         admin    ALL             false
test           pg_catalog   jsonb           type         root     ALL             false
test           pg_catalog   jsonb[]         type         admin    ALL             false
test           pg_catalog   jsonb[]         type         root     ALL             false
test           pg_catalog   name            type         admin    ALL             false
test           pg_catalog   name            type         root     ALL             false
test           pg_catalog   name[]          type         admin    ALL             false
test           pg_catalog   name[]          type         root     ALL             false
test           pg_catalog   oid             type         admin    ALL             false
test           pg_catalog   oid             type         root     ALL             false
test           pg_catalog   oid[]           type         admin    ALL             false
test           pg_catalog   oid[]           type         root     ALL             false
test           pg_catalog   oidvector       type         admin    ALL             false
test           pg_catalog   oidvector       type         root     ALL             false
test           pg_catalog   oidvector[]     type         admin    ALL             false
test           pg_catalog   oidvector[]     type         root     ALL             false
test           pg_catalog   pg_lsn          type         admin    ALL             false
test           pg_catalog   pg_lsn          type         root     ALL             false
test           pg_catalog   pg_lsn[]        type         admin    ALL             false
test           pg_catalog   pg_lsn[]        type         root     ALL             false
test           pg_catalog   record          type         admin    ALL             false
test           pg_catalog   record          type         root     ALL             false
test           pg_catalog   record[]        type         admin    ALL             false
test           pg_catalog   record[]        type         root     ALL             false
test           pg_catalog   refcursor       type         admin    ALL             false
test           pg_catalog   refcursor       type         root     ALL             false
test           pg_catalog   refcursor[]     type         admin    ALL             false
test           pg_catalog   refcursor[]     type         root     ALL             false
test           pg_catalog   regclass        type         admin    ALL             false
test           pg_catalog   regclass        type         root     ALL             false
test           pg_catalog   regclass[]      type         admin    ALL             false
test           pg_catalog   regclass[]      type         root     ALL             false
test           pg_catalog   regnamespace    type         admin    ALL             false
test           pg_catalog   regnamespace    type         root     ALL             false
test           pg_catalog   regnamespace[]  type         admin    ALL             false
test           pg_catalog   regnamespace[]  type         root     ALL             false
test           pg_catalog   regproc         type         admin    ALL             false
test           pg_catalog   regproc         type         root     ALL             false
test           pg_catalog   regproc[]       type         admin    ALL             false
test           pg_catalog   regproc[]       type         root     ALL             false
test           pg_catalog   regprocedure    type         admin    ALL             false
test           pg_catalog   regprocedure    type         root     ALL             false
test           pg_catalog   regprocedure[]  type         admin    ALL             false
test           pg_catalog   regprocedure[]  type         root     ALL             false
test           pg_catalog   regrole         type         admin    ALL             false
test           pg_catalog   regrole         type         root     ALL             false
test           pg_catalog   regrole[]       type         admin    ALL             false
test           pg_catalog   regrole[]       type         root     ALL             false
test           pg_catalog   regtype         type         admin    ALL             false
test           pg_catalog   regtype         type         root     ALL             false
test           pg_catalog   regtype[]       type         admin    ALL             false
test           pg_catalog   regtype[]       type         root     ALL             false
test           pg_catalog   string          type         admin    ALL             false
test           pg_catalog   string          type         root     ALL             false
test           pg_catalog   string[]        type         admin    ALL             false
test           pg_catalog   string[]        type         root     ALL             false
test           pg_catalog   time            type         admin    ALL             false
test           pg_catalog   time            type         root     ALL             false
test           pg_catalog   time[]          type         admin    ALL             false
test           pg_catalog   time[]          type         root     ALL             false
test           pg_catalog   timestamp       type         admin    ALL             false
test           pg_catalog   timestamp       type         root     ALL             false
test           pg_catalog   timestamp[]     type         admin    ALL             false
test           pg_catalog   timestamp[]     type         root     ALL             false
test           pg_catalog   timestamptz     type         admin    ALL             false
test           pg_catalog   timestamptz     type         root     ALL             false
test           pg_catalog   timestamptz[]   type         admin    ALL             false
test           pg_catalog   timestamptz[]   type         root     ALL             false
test           pg_catalog   timetz          type         admin    ALL             false
test           pg_catalog   timetz          type         root     ALL             false
test           pg_catalog   timetz[]        type         admin    ALL             false
test           pg_catalog   timetz[]        type         root     ALL             false
test           pg_catalog   trigger         type         admin    ALL             false
test           pg_catalog   trigger         type         root     ALL             false
test           pg_catalog   tsquery         type         admin    ALL             false
test           pg_catalog   tsquery         type         root     ALL             false
test           pg_catalog   tsquery[]       type         admin    ALL             false
test           pg_catalog   tsquery[]       type         root     ALL             false
test           pg_catalog   tsvector        type         admin    ALL             false
test           pg_catalog   tsvector        type         root     ALL             false
test           pg_catalog   tsvector[]      type         admin    ALL             false
test           pg_catalog   tsvector[]      type         root     ALL             false
test           pg_catalog   unknown         type         admin    ALL             false
test           pg_catalog   unknown         type         root     ALL             false
test           pg_catalog   uuid            type         admin    ALL             false
test           pg_catalog   uuid            type         root     ALL             false
test           pg_catalog   uuid[]          type         admin    ALL             false
test           pg_catalog   uuid[]          type         root     ALL             false
test           pg_catalog   varbit          type         admin    ALL             false
test           pg_catalog   varbit          type         root     ALL             false
test           pg_catalog   varbit[]        type         admin    ALL             false
test           pg_catalog   varbit[]        type         root     ALL             false
test           pg_catalog   varchar         type         admin    ALL             false
test           pg_catalog   varchar         type         root     ALL             false
test           pg_catalog   varchar[]       type         admin    ALL             false
test           pg_catalog   varchar[]       type         root     ALL             false
test           pg_catalog   vector          type         admin    ALL             false
test           pg_catalog   vector          type         root     ALL             false
test           pg_catalog   vector[]        type         admin    ALL             false
test           pg_catalog   vector[]        type         root     ALL             false
test           pg_catalog   void            type         admin    ALL             false
test           pg_catalog   void            type         root     ALL             false
test           public       NULL            schema       admin    ALL             true
test           public       NULL            schema       public   CREATE          false
test           public       NULL            schema       public   USAGE           false
test           public       NULL            schema       root     ALL             true

# With no database set, we show the grants everywhere
statement ok
SET DATABASE = ''

# Filter system results so that so we are not enumerating the entire system
# and making this test brittle and overly broad but leave one specifically chosen
# system table in just to confirm they were there before filtering.
query TTTTTTB colnames,rowsort
WITH grants AS (SHOW GRANTS) SELECT * FROM grants
 WHERE schema_name NOT IN ('crdb_internal', 'pg_catalog', 'information_schema') 
  AND (database_name <> 'system' OR object_name = 'role_options')
----
database_name  schema_name   object_name        object_type  grantee  privilege_type  is_grantable
system         public        role_options       table        admin    DELETE          true
test           public        NULL               schema       admin    ALL             true
postgres       public        NULL               schema       admin    ALL             true
defaultdb      public        NULL               schema       admin    ALL             true
a              public        NULL               schema       admin    ALL             true
system         public        role_options       table        admin    UPDATE          true
system         public        role_options       table        admin    SELECT          true
system         public        role_options       table        admin    INSERT          true
defaultdb      pg_extension  geography_columns  table        public   SELECT          false
defaultdb      pg_extension  geometry_columns   table        public   SELECT          false
defaultdb      pg_extension  spatial_ref_sys    table        public   SELECT          false
postgres       pg_extension  geography_columns  table        public   SELECT          false
postgres       pg_extension  geometry_columns   table        public   SELECT          false
postgres       pg_extension  spatial_ref_sys    table        public   SELECT          false
test           pg_extension  geography_columns  table        public   SELECT          false
test           pg_extension  geometry_columns   table        public   SELECT          false
test           pg_extension  spatial_ref_sys    table        public   SELECT          false
a              pg_extension  geography_columns  table        public   SELECT          false
a              pg_extension  geometry_columns   table        public   SELECT          false
a              pg_extension  spatial_ref_sys    table        public   SELECT          false
system         public        role_options       table        root     DELETE          true
system         public        role_options       table        root     INSERT          true
system         public        role_options       table        root     SELECT          true
system         public        role_options       table        root     UPDATE          true
a              pg_extension  NULL               schema       public   USAGE           false
a              public        NULL               schema       public   CREATE          false
a              public        NULL               schema       public   USAGE           false
a              public        NULL               schema       root     ALL             true
defaultdb      pg_extension  NULL               schema       public   USAGE           false
defaultdb      public        NULL               schema       public   CREATE          false
defaultdb      public        NULL               schema       public   USAGE           false
defaultdb      public        NULL               schema       root     ALL             true
postgres       pg_extension  NULL               schema       public   USAGE           false
postgres       public        NULL               schema       public   CREATE          false
postgres       public        NULL               schema       public   USAGE           false
postgres       public        NULL               schema       root     ALL             true
test           pg_extension  NULL               schema       public   USAGE           false
test           public        NULL               schema       public   CREATE          false
test           public        NULL               schema       public   USAGE           false
test           public        NULL               schema       root     ALL             true

query TTTTTTB colnames,rowsort
WITH grants AS (SHOW GRANTS FOR root) SELECT * FROM grants 
WHERE (database_name <> 'system' OR object_name = 'role_options')
----
database_name  schema_name  object_name     object_type  grantee  privilege_type  is_grantable
system         public       role_options    table        admin    DELETE          true
system         public       role_options    table        admin    INSERT          true
system         public       role_options    table        admin    SELECT          true
system         public       role_options    table        admin    UPDATE          true
a              public       NULL            schema       admin    ALL             true
defaultdb      public       NULL            schema       admin    ALL             true
postgres       public       NULL            schema       admin    ALL             true
test           public       NULL            schema       admin    ALL             true
a              NULL         NULL            database     admin    ALL             true
defaultdb      NULL         NULL            database     admin    ALL             true
postgres       NULL         NULL            database     admin    ALL             true
test           NULL         NULL            database     admin    ALL             true
a              pg_catalog   varchar[]       type         admin    ALL             false
a              pg_catalog   bpchar          type         admin    ALL             false
a              pg_catalog   int2[]          type         admin    ALL             false
a              pg_catalog   timestamptz[]   type         admin    ALL             false
a              pg_catalog   geography[]     type         admin    ALL             false
a              pg_catalog   record[]        type         admin    ALL             false
a              pg_catalog   string          type         admin    ALL             false
a              pg_catalog   tsvector        type         admin    ALL             false
a              pg_catalog   regrole[]       type         admin    ALL             false
a              pg_catalog   bool            type         admin    ALL             false
a              pg_catalog   "char"          type         admin    ALL             false
a              pg_catalog   float           type         admin    ALL             false
a              pg_catalog   int2            type         admin    ALL             false
a              pg_catalog   record          type         admin    ALL             false
a              pg_catalog   int             type         admin    ALL             false
a              pg_catalog   int4[]          type         admin    ALL             false
a              pg_catalog   float[]         type         admin    ALL             false
a              pg_catalog   jsonb[]         type         admin    ALL             false
a              pg_catalog   date[]          type         admin    ALL             false
a              pg_catalog   regprocedure[]  type         admin    ALL             false
a              pg_catalog   name            type         admin    ALL             false
a              pg_catalog   varchar         type         admin    ALL             false
a              pg_catalog   geometry        type         admin    ALL             false
a              pg_catalog   box2d[]         type         admin    ALL             false
a              pg_catalog   tsvector[]      type         admin    ALL             false
a              pg_catalog   box2d           type         admin    ALL             false
a              pg_catalog   anyarray        type         admin    ALL             false
a              pg_catalog   pg_lsn          type         admin    ALL             false
a              pg_catalog   regprocedure    type         admin    ALL             false
a              pg_catalog   time[]          type         admin    ALL             false
a              pg_catalog   regproc[]       type         admin    ALL             false
a              pg_catalog   timestamp[]     type         admin    ALL             false
a              pg_catalog   name[]          type         admin    ALL             false
a              pg_catalog   date            type         admin    ALL             false
a              pg_catalog   int4            type         admin    ALL             false
a              pg_catalog   decimal         type         admin    ALL             false
a              pg_catalog   regnamespace    type         admin    ALL             false
a              pg_catalog   regproc         type         admin    ALL             false
a              pg_catalog   timestamp       type         admin    ALL             false
a              pg_catalog   uuid[]          type         admin    ALL             false
a              pg_catalog   bit[]           type         admin    ALL             false
a              pg_catalog   bit             type         admin    ALL             false
a              pg_catalog   bytes           type         admin    ALL             false
a              pg_catalog   float4          type         admin    ALL             false
a              pg_catalog   unknown         type         admin    ALL             false
a              pg_catalog   float4[]        type         admin    ALL             false
a              pg_catalog   pg_lsn[]        type         admin    ALL             false
a              pg_catalog   regclass[]      type         admin    ALL             false
a              pg_catalog   "char"[]        type         admin    ALL             false
a              pg_catalog   interval        type         admin    ALL             false
a              pg_catalog   refcursor       type         admin    ALL             false
a              pg_catalog   regtype         type         admin    ALL             false
a              pg_catalog   time            type         admin    ALL             false
a              pg_catalog   void            type         admin    ALL             false
a              pg_catalog   oid[]           type         admin    ALL             false
a              pg_catalog   regnamespace[]  type         admin    ALL             false
a              pg_catalog   timetz          type         admin    ALL             false
a              pg_catalog   regtype[]       type         admin    ALL             false
a              pg_catalog   int[]           type         admin    ALL             false
a              pg_catalog   interval[]      type         admin    ALL             false
a              pg_catalog   varbit[]        type         admin    ALL             false
a              pg_catalog   int2vector      type         admin    ALL             false
a              pg_catalog   jsonb           type         admin    ALL             false
a              pg_catalog   bpchar[]        type         admin    ALL             false
a              pg_catalog   refcursor[]     type         admin    ALL             false
a              pg_catalog   oid             type         admin    ALL             false
a              pg_catalog   timestamptz     type         admin    ALL             false
a              pg_catalog   vector          type         admin    ALL             false
a              pg_catalog   vector[]        type         admin    ALL             false
a              pg_catalog   anyelement      type         admin    ALL             false
a              pg_catalog   inet            type         admin    ALL             false
a              pg_catalog   bool[]          type         admin    ALL             false
a              pg_catalog   decimal[]       type         admin    ALL             false
a              pg_catalog   oidvector[]     type         admin    ALL             false
a              pg_catalog   inet[]          type         admin    ALL             false
a              pg_catalog   int2vector[]    type         admin    ALL             false
a              pg_catalog   bytes[]         type         admin    ALL             false
a              pg_catalog   oidvector       type         admin    ALL             false
a              pg_catalog   regclass        type         admin    ALL             false
a              pg_catalog   trigger         type         admin    ALL             false
a              pg_catalog   varbit          type         admin    ALL             false
a              pg_catalog   geometry[]      type         admin    ALL             false
a              pg_catalog   timetz[]        type         admin    ALL             false
a              pg_catalog   tsquery[]       type         admin    ALL             false
a              pg_catalog   regrole         type         admin    ALL             false
a              pg_catalog   tsquery         type         admin    ALL             false
a              pg_catalog   uuid            type         admin    ALL             false
a              pg_catalog   geography       type         admin    ALL             false
a              pg_catalog   string[]        type         admin    ALL             false
defaultdb      pg_catalog   jsonb[]         type         admin    ALL             false
defaultdb      pg_catalog   date[]          type         admin    ALL             false
defaultdb      pg_catalog   int             type         admin    ALL             false
defaultdb      pg_catalog   int4[]          type         admin    ALL             false
defaultdb      pg_catalog   float[]         type         admin    ALL             false
defaultdb      pg_catalog   box2d[]         type         admin    ALL             false
defaultdb      pg_catalog   tsvector[]      type         admin    ALL             false
defaultdb      pg_catalog   regprocedure[]  type         admin    ALL             false
defaultdb      pg_catalog   name            type         admin    ALL             false
defaultdb      pg_catalog   varchar         type         admin    ALL             false
defaultdb      pg_catalog   geometry        type         admin    ALL             false
defaultdb      pg_catalog   box2d           type         admin    ALL             false
defaultdb      pg_catalog   anyarray        type         admin    ALL             false
defaultdb      pg_catalog   regproc[]       type         admin    ALL             false
defaultdb      pg_catalog   pg_lsn          type         admin    ALL             false
defaultdb      pg_catalog   regprocedure    type         admin    ALL             false
defaultdb      pg_catalog   time[]          type         admin    ALL             false
defaultdb      pg_catalog   regnamespace    type         admin    ALL             false
defaultdb      pg_catalog   regproc         type         admin    ALL             false
defaultdb      pg_catalog   timestamp[]     type         admin    ALL             false
defaultdb      pg_catalog   name[]          type         admin    ALL             false
defaultdb      pg_catalog   date            type         admin    ALL             false
defaultdb      pg_catalog   int4            type         admin    ALL             false
defaultdb      pg_catalog   decimal         type         admin    ALL             false
defaultdb      pg_catalog   timestamp       type         admin    ALL             false
defaultdb      pg_catalog   uuid[]          type         admin    ALL             false
defaultdb      pg_catalog   bit[]           type         admin    ALL             false
defaultdb      pg_catalog   unknown         type         admin    ALL             false
defaultdb      pg_catalog   float4[]        type         admin    ALL             false
defaultdb      pg_catalog   bit             type         admin    ALL             false
defaultdb      pg_catalog   bytes           type         admin    ALL             false
defaultdb      pg_catalog   float4          type         admin    ALL             false
defaultdb      pg_catalog   time            type         admin    ALL             false
defaultdb      pg_catalog   void            type         admin    ALL             false
defaultdb      pg_catalog   pg_lsn[]        type         admin    ALL             false
defaultdb      pg_catalog   regclass[]      type         admin    ALL             false
defaultdb      pg_catalog   "char"[]        type         admin    ALL             false
defaultdb      pg_catalog   interval        type         admin    ALL             false
defaultdb      pg_catalog   refcursor       type         admin    ALL             false
defaultdb      pg_catalog   regtype         type         admin    ALL             false
defaultdb      pg_catalog   oid[]           type         admin    ALL             false
defaultdb      pg_catalog   interval[]      type         admin    ALL             false
defaultdb      pg_catalog   varbit[]        type         admin    ALL             false
defaultdb      pg_catalog   regnamespace[]  type         admin    ALL             false
defaultdb      pg_catalog   timetz          type         admin    ALL             false
defaultdb      pg_catalog   regtype[]       type         admin    ALL             false
defaultdb      pg_catalog   int[]           type         admin    ALL             false
defaultdb      pg_catalog   refcursor[]     type         admin    ALL             false
defaultdb      pg_catalog   int2vector      type         admin    ALL             false
defaultdb      pg_catalog   jsonb           type         admin    ALL             false
defaultdb      pg_catalog   bpchar[]        type         admin    ALL             false
defaultdb      pg_catalog   oid             type         admin    ALL             false
defaultdb      pg_catalog   timestamptz     type         admin    ALL             false
defaultdb      pg_catalog   vector          type         admin    ALL             false
defaultdb      pg_catalog   decimal[]       type         admin    ALL             false
defaultdb      pg_catalog   oidvector[]     type         admin    ALL             false
defaultdb      pg_catalog   vector[]        type         admin    ALL             false
defaultdb      pg_catalog   anyelement      type         admin    ALL             false
defaultdb      pg_catalog   inet            type         admin    ALL             false
defaultdb      pg_catalog   bool[]          type         admin    ALL             false
defaultdb      pg_catalog   varbit          type         admin    ALL             false
defaultdb      pg_catalog   geometry[]      type         admin    ALL             false
defaultdb      pg_catalog   inet[]          type         admin    ALL             false
defaultdb      pg_catalog   int2vector[]    type         admin    ALL             false
defaultdb      pg_catalog   bytes[]         type         admin    ALL             false
defaultdb      pg_catalog   oidvector       type         admin    ALL             false
defaultdb      pg_catalog   regclass        type         admin    ALL             false
defaultdb      pg_catalog   trigger         type         admin    ALL             false
defaultdb      pg_catalog   geography       type         admin    ALL             false
defaultdb      pg_catalog   string[]        type         admin    ALL             false
defaultdb      pg_catalog   timetz[]        type         admin    ALL             false
defaultdb      pg_catalog   tsquery[]       type         admin    ALL             false
defaultdb      pg_catalog   regrole         type         admin    ALL             false
defaultdb      pg_catalog   tsquery         type         admin    ALL             false
defaultdb      pg_catalog   uuid            type         admin    ALL             false
defaultdb      pg_catalog   geography[]     type         admin    ALL             false
defaultdb      pg_catalog   record[]        type         admin    ALL             false
defaultdb      pg_catalog   varchar[]       type         admin    ALL             false
defaultdb      pg_catalog   bpchar          type         admin    ALL             false
defaultdb      pg_catalog   int2[]          type         admin    ALL             false
defaultdb      pg_catalog   timestamptz[]   type         admin    ALL             false
defaultdb      pg_catalog   int2            type         admin    ALL             false
defaultdb      pg_catalog   record          type         admin    ALL             false
defaultdb      pg_catalog   string          type         admin    ALL             false
defaultdb      pg_catalog   tsvector        type         admin    ALL             false
defaultdb      pg_catalog   regrole[]       type         admin    ALL             false
defaultdb      pg_catalog   bool            type         admin    ALL             false
defaultdb      pg_catalog   "char"          type         admin    ALL             false
defaultdb      pg_catalog   float           type         admin    ALL             false
postgres       pg_catalog   timestamp       type         admin    ALL             false
postgres       pg_catalog   uuid[]          type         admin    ALL             false
postgres       pg_catalog   bit[]           type         admin    ALL             false
postgres       pg_catalog   float4[]        type         admin    ALL             false
postgres       pg_catalog   bit             type         admin    ALL             false
postgres       pg_catalog   bytes           type         admin    ALL             false
postgres       pg_catalog   float4          type         admin    ALL             false
postgres       pg_catalog   unknown         type         admin    ALL             false
postgres       pg_catalog   void            type         admin    ALL             false
postgres       pg_catalog   pg_lsn[]        type         admin    ALL             false
postgres       pg_catalog   regclass[]      type         admin    ALL             false
postgres       pg_catalog   "char"[]        type         admin    ALL             false
postgres       pg_catalog   interval        type         admin    ALL             false
postgres       pg_catalog   refcursor       type         admin    ALL             false
postgres       pg_catalog   regtype         type         admin    ALL             false
postgres       pg_catalog   time            type         admin    ALL             false
postgres       pg_catalog   oid[]           type         admin    ALL             false
postgres       pg_catalog   varbit[]        type         admin    ALL             false
postgres       pg_catalog   regnamespace[]  type         admin    ALL             false
postgres       pg_catalog   timetz          type         admin    ALL             false
postgres       pg_catalog   regtype[]       type         admin    ALL             false
postgres       pg_catalog   int[]           type         admin    ALL             false
postgres       pg_catalog   interval[]      type         admin    ALL             false
postgres       pg_catalog   int2vector      type         admin    ALL             false
postgres       pg_catalog   jsonb           type         admin    ALL             false
postgres       pg_catalog   bpchar[]        type         admin    ALL             false
postgres       pg_catalog   refcursor[]     type         admin    ALL             false
postgres       pg_catalog   oid             type         admin    ALL             false
postgres       pg_catalog   timestamptz     type         admin    ALL             false
postgres       pg_catalog   vector          type         admin    ALL             false
postgres       pg_catalog   oidvector[]     type         admin    ALL             false
postgres       pg_catalog   vector[]        type         admin    ALL             false
postgres       pg_catalog   anyelement      type         admin    ALL             false
postgres       pg_catalog   inet            type         admin    ALL             false
postgres       pg_catalog   bool[]          type         admin    ALL             false
postgres       pg_catalog   decimal[]       type         admin    ALL             false
postgres       pg_catalog   geometry[]      type         admin    ALL             false
postgres       pg_catalog   inet[]          type         admin    ALL             false
postgres       pg_catalog   int2vector[]    type         admin    ALL             false
postgres       pg_catalog   bytes[]         type         admin    ALL             false
postgres       pg_catalog   oidvector       type         admin    ALL             false
postgres       pg_catalog   regclass        type         admin    ALL             false
postgres       pg_catalog   trigger         type         admin    ALL             false
postgres       pg_catalog   varbit          type         admin    ALL             false
postgres       pg_catalog   string[]        type         admin    ALL             false
postgres       pg_catalog   timetz[]        type         admin    ALL             false
postgres       pg_catalog   tsquery[]       type         admin    ALL             false
postgres       pg_catalog   regrole         type         admin    ALL             false
postgres       pg_catalog   tsquery         type         admin    ALL             false
postgres       pg_catalog   uuid            type         admin    ALL             false
postgres       pg_catalog   geography       type         admin    ALL             false
postgres       pg_catalog   record[]        type         admin    ALL             false
postgres       pg_catalog   varchar[]       type         admin    ALL             false
postgres       pg_catalog   bpchar          type         admin    ALL             false
postgres       pg_catalog   int2[]          type         admin    ALL             false
postgres       pg_catalog   timestamptz[]   type         admin    ALL             false
postgres       pg_catalog   geography[]     type         admin    ALL             false
postgres       pg_catalog   record          type         admin    ALL             false
postgres       pg_catalog   string          type         admin    ALL             false
postgres       pg_catalog   tsvector        type         admin    ALL             false
postgres       pg_catalog   regrole[]       type         admin    ALL             false
postgres       pg_catalog   bool            type         admin    ALL             false
postgres       pg_catalog   "char"          type         admin    ALL             false
postgres       pg_catalog   float           type         admin    ALL             false
postgres       pg_catalog   int2            type         admin    ALL             false
postgres       pg_catalog   date[]          type         admin    ALL             false
postgres       pg_catalog   int             type         admin    ALL             false
postgres       pg_catalog   int4[]          type         admin    ALL             false
postgres       pg_catalog   float[]         type         admin    ALL             false
postgres       pg_catalog   jsonb[]         type         admin    ALL             false
postgres       pg_catalog   tsvector[]      type         admin    ALL             false
postgres       pg_catalog   regprocedure[]  type         admin    ALL             false
postgres       pg_catalog   name            type         admin    ALL             false
postgres       pg_catalog   varchar         type         admin    ALL             false
postgres       pg_catalog   geometry        type         admin    ALL             false
postgres       pg_catalog   box2d[]         type         admin    ALL             false
postgres       pg_catalog   box2d           type         admin    ALL             false
postgres       pg_catalog   anyarray        type         admin    ALL             false
postgres       pg_catalog   pg_lsn          type         admin    ALL             false
postgres       pg_catalog   regprocedure    type         admin    ALL             false
postgres       pg_catalog   time[]          type         admin    ALL             false
postgres       pg_catalog   regproc[]       type         admin    ALL             false
postgres       pg_catalog   regproc         type         admin    ALL             false
postgres       pg_catalog   timestamp[]     type         admin    ALL             false
postgres       pg_catalog   name[]          type         admin    ALL             false
postgres       pg_catalog   date            type         admin    ALL             false
postgres       pg_catalog   int4            type         admin    ALL             false
postgres       pg_catalog   decimal         type         admin    ALL             false
postgres       pg_catalog   regnamespace    type         admin    ALL             false
test           pg_catalog   varchar[]       type         admin    ALL             false
test           pg_catalog   bpchar          type         admin    ALL             false
test           pg_catalog   int2[]          type         admin    ALL             false
test           pg_catalog   timestamptz[]   type         admin    ALL             false
test           pg_catalog   geography[]     type         admin    ALL             false
test           pg_catalog   record[]        type         admin    ALL             false
test           pg_catalog   string          type         admin    ALL             false
test           pg_catalog   tsvector        type         admin    ALL             false
test           pg_catalog   regrole[]       type         admin    ALL             false
test           pg_catalog   bool            type         admin    ALL             false
test           pg_catalog   "char"          type         admin    ALL             false
test           pg_catalog   float           type         admin    ALL             false
test           pg_catalog   int2            type         admin    ALL             false
test           pg_catalog   record          type         admin    ALL             false
test           pg_catalog   int             type         admin    ALL             false
test           pg_catalog   int4[]          type         admin    ALL             false
test           pg_catalog   float[]         type         admin    ALL             false
test           pg_catalog   jsonb[]         type         admin    ALL             false
test           pg_catalog   date[]          type         admin    ALL             false
test           pg_catalog   regprocedure[]  type         admin    ALL             false
test           pg_catalog   name            type         admin    ALL             false
test           pg_catalog   varchar         type         admin    ALL             false
test           pg_catalog   geometry        type         admin    ALL             false
test           pg_catalog   box2d[]         type         admin    ALL             false
test           pg_catalog   tsvector[]      type         admin    ALL             false
test           pg_catalog   box2d           type         admin    ALL             false
test           pg_catalog   anyarray        type         admin    ALL             false
test           pg_catalog   pg_lsn          type         admin    ALL             false
test           pg_catalog   regprocedure    type         admin    ALL             false
test           pg_catalog   time[]          type         admin    ALL             false
test           pg_catalog   regproc[]       type         admin    ALL             false
test           pg_catalog   timestamp[]     type         admin    ALL             false
test           pg_catalog   name[]          type         admin    ALL             false
test           pg_catalog   date            type         admin    ALL             false
test           pg_catalog   int4            type         admin    ALL             false
test           pg_catalog   decimal         type         admin    ALL             false
test           pg_catalog   regnamespace    type         admin    ALL             false
test           pg_catalog   regproc         type         admin    ALL             false
test           pg_catalog   timestamp       type         admin    ALL             false
test           pg_catalog   uuid[]          type         admin    ALL             false
test           pg_catalog   bit[]           type         admin    ALL             false
test           pg_catalog   bit             type         admin    ALL             false
test           pg_catalog   bytes           type         admin    ALL             false
test           pg_catalog   float4          type         admin    ALL             false
test           pg_catalog   unknown         type         admin    ALL             false
test           pg_catalog   float4[]        type         admin    ALL             false
test           pg_catalog   pg_lsn[]        type         admin    ALL             false
test           pg_catalog   regclass[]      type         admin    ALL             false
test           pg_catalog   "char"[]        type         admin    ALL             false
test           pg_catalog   interval        type         admin    ALL             false
test           pg_catalog   refcursor       type         admin    ALL             false
test           pg_catalog   regtype         type         admin    ALL             false
test           pg_catalog   time            type         admin    ALL             false
test           pg_catalog   void            type         admin    ALL             false
test           pg_catalog   oid[]           type         admin    ALL             false
test           pg_catalog   regnamespace[]  type         admin    ALL             false
test           pg_catalog   timetz          type         admin    ALL             false
test           pg_catalog   regtype[]       type         admin    ALL             false
test           pg_catalog   int[]           type         admin    ALL             false
test           pg_catalog   interval[]      type         admin    ALL             false
test           pg_catalog   varbit[]        type         admin    ALL             false
test           pg_catalog   int2vector      type         admin    ALL             false
test           pg_catalog   jsonb           type         admin    ALL             false
test           pg_catalog   bpchar[]        type         admin    ALL             false
test           pg_catalog   refcursor[]     type         admin    ALL             false
test           pg_catalog   oid             type         admin    ALL             false
test           pg_catalog   timestamptz     type         admin    ALL             false
test           pg_catalog   vector          type         admin    ALL             false
test           pg_catalog   vector[]        type         admin    ALL             false
test           pg_catalog   anyelement      type         admin    ALL             false
test           pg_catalog   inet            type         admin    ALL             false
test           pg_catalog   bool[]          type         admin    ALL             false
test           pg_catalog   decimal[]       type         admin    ALL             false
test           pg_catalog   oidvector[]     type         admin    ALL             false
test           pg_catalog   inet[]          type         admin    ALL             false
test           pg_catalog   int2vector[]    type         admin    ALL             false
test           pg_catalog   bytes[]         type         admin    ALL             false
test           pg_catalog   oidvector       type         admin    ALL             false
test           pg_catalog   regclass        type         admin    ALL             false
test           pg_catalog   trigger         type         admin    ALL             false
test           pg_catalog   varbit          type         admin    ALL             false
test           pg_catalog   geometry[]      type         admin    ALL             false
test           pg_catalog   timetz[]        type         admin    ALL             false
test           pg_catalog   tsquery[]       type         admin    ALL             false
test           pg_catalog   regrole         type         admin    ALL             false
test           pg_catalog   tsquery         type         admin    ALL             false
test           pg_catalog   uuid            type         admin    ALL             false
test           pg_catalog   geography       type         admin    ALL             false
test           pg_catalog   string[]        type         admin    ALL             false
system         public       role_options    table        root     DELETE          true
system         public       role_options    table        root     INSERT          true
system         public       role_options    table        root     SELECT          true
system         public       role_options    table        root     UPDATE          true
a              public       NULL            schema       root     ALL             true
defaultdb      public       NULL            schema       root     ALL             true
postgres       public       NULL            schema       root     ALL             true
test           public       NULL            schema       root     ALL             true
a              NULL         NULL            database     root     ALL             true
defaultdb      NULL         NULL            database     root     ALL             true
postgres       NULL         NULL            database     root     ALL             true
test           NULL         NULL            database     root     ALL             true
a              pg_catalog   varchar[]       type         root     ALL             false
a              pg_catalog   bpchar          type         root     ALL             false
a              pg_catalog   int2[]          type         root     ALL             false
a              pg_catalog   timestamptz[]   type         root     ALL             false
a              pg_catalog   geography[]     type         root     ALL             false
a              pg_catalog   record[]        type         root     ALL             false
a              pg_catalog   string          type         root     ALL             false
a              pg_catalog   tsvector        type         root     ALL             false
a              pg_catalog   regrole[]       type         root     ALL             false
a              pg_catalog   bool            type         root     ALL             false
a              pg_catalog   "char"          type         root     ALL             false
a              pg_catalog   float           type         root     ALL             false
a              pg_catalog   int2            type         root     ALL             false
a              pg_catalog   record          type         root     ALL             false
a              pg_catalog   int             type         root     ALL             false
a              pg_catalog   int4[]          type         root     ALL             false
a              pg_catalog   float[]         type         root     ALL             false
a              pg_catalog   jsonb[]         type         root     ALL             false
a              pg_catalog   date[]          type         root     ALL             false
a              pg_catalog   regprocedure[]  type         root     ALL             false
a              pg_catalog   name            type         root     ALL             false
a              pg_catalog   varchar         type         root     ALL             false
a              pg_catalog   geometry        type         root     ALL             false
a              pg_catalog   box2d[]         type         root     ALL             false
a              pg_catalog   tsvector[]      type         root     ALL             false
a              pg_catalog   box2d           type         root     ALL             false
a              pg_catalog   anyarray        type         root     ALL             false
a              pg_catalog   pg_lsn          type         root     ALL             false
a              pg_catalog   regprocedure    type         root     ALL             false
a              pg_catalog   time[]          type         root     ALL             false
a              pg_catalog   regproc[]       type         root     ALL             false
a              pg_catalog   timestamp[]     type         root     ALL             false
a              pg_catalog   name[]          type         root     ALL             false
a              pg_catalog   date            type         root     ALL             false
a              pg_catalog   int4            type         root     ALL             false
a              pg_catalog   decimal         type         root     ALL             false
a              pg_catalog   regnamespace    type         root     ALL             false
a              pg_catalog   regproc         type         root     ALL             false
a              pg_catalog   timestamp       type         root     ALL             false
a              pg_catalog   uuid[]          type         root     ALL             false
a              pg_catalog   bit[]           type         root     ALL             false
a              pg_catalog   bit             type         root     ALL             false
a              pg_catalog   bytes           type         root     ALL             false
a              pg_catalog   float4          type         root     ALL             false
a              pg_catalog   unknown         type         root     ALL             false
a              pg_catalog   float4[]        type         root     ALL             false
a              pg_catalog   pg_lsn[]        type         root     ALL             false
a              pg_catalog   regclass[]      type         root     ALL             false
a              pg_catalog   "char"[]        type         root     ALL             false
a              pg_catalog   interval        type         root     ALL             false
a              pg_catalog   refcursor       type         root     ALL             false
a              pg_catalog   regtype         type         root     ALL             false
a              pg_catalog   time            type         root     ALL             false
a              pg_catalog   void            type         root     ALL             false
a              pg_catalog   oid[]           type         root     ALL             false
a              pg_catalog   regnamespace[]  type         root     ALL             false
a              pg_catalog   timetz          type         root     ALL             false
a              pg_catalog   regtype[]       type         root     ALL             false
a              pg_catalog   int[]           type         root     ALL             false
a              pg_catalog   interval[]      type         root     ALL             false
a              pg_catalog   varbit[]        type         root     ALL             false
a              pg_catalog   int2vector      type         root     ALL             false
a              pg_catalog   jsonb           type         root     ALL             false
a              pg_catalog   bpchar[]        type         root     ALL             false
a              pg_catalog   refcursor[]     type         root     ALL             false
a              pg_catalog   oid             type         root     ALL             false
a              pg_catalog   timestamptz     type         root     ALL             false
a              pg_catalog   vector          type         root     ALL             false
a              pg_catalog   vector[]        type         root     ALL             false
a              pg_catalog   anyelement      type         root     ALL             false
a              pg_catalog   inet            type         root     ALL             false
a              pg_catalog   bool[]          type         root     ALL             false
a              pg_catalog   decimal[]       type         root     ALL             false
a              pg_catalog   oidvector[]     type         root     ALL             false
a              pg_catalog   inet[]          type         root     ALL             false
a              pg_catalog   int2vector[]    type         root     ALL             false
a              pg_catalog   bytes[]         type         root     ALL             false
a              pg_catalog   oidvector       type         root     ALL             false
a              pg_catalog   regclass        type         root     ALL             false
a              pg_catalog   trigger         type         root     ALL             false
a              pg_catalog   varbit          type         root     ALL             false
a              pg_catalog   geometry[]      type         root     ALL             false
a              pg_catalog   timetz[]        type         root     ALL             false
a              pg_catalog   tsquery[]       type         root     ALL             false
a              pg_catalog   regrole         type         root     ALL             false
a              pg_catalog   tsquery         type         root     ALL             false
a              pg_catalog   uuid            type         root     ALL             false
a              pg_catalog   geography       type         root     ALL             false
a              pg_catalog   string[]        type         root     ALL             false
defaultdb      pg_catalog   jsonb[]         type         root     ALL             false
defaultdb      pg_catalog   date[]          type         root     ALL             false
defaultdb      pg_catalog   int             type         root     ALL             false
defaultdb      pg_catalog   int4[]          type         root     ALL             false
defaultdb      pg_catalog   float[]         type         root     ALL             false
defaultdb      pg_catalog   box2d[]         type         root     ALL             false
defaultdb      pg_catalog   tsvector[]      type         root     ALL             false
defaultdb      pg_catalog   regprocedure[]  type         root     ALL             false
defaultdb      pg_catalog   name            type         root     ALL             false
defaultdb      pg_catalog   varchar         type         root     ALL             false
defaultdb      pg_catalog   geometry        type         root     ALL             false
defaultdb      pg_catalog   box2d           type         root     ALL             false
defaultdb      pg_catalog   anyarray        type         root     ALL             false
defaultdb      pg_catalog   regproc[]       type         root     ALL             false
defaultdb      pg_catalog   pg_lsn          type         root     ALL             false
defaultdb      pg_catalog   regprocedure    type         root     ALL             false
defaultdb      pg_catalog   time[]          type         root     ALL             false
defaultdb      pg_catalog   regnamespace    type         root     ALL             false
defaultdb      pg_catalog   regproc         type         root     ALL             false
defaultdb      pg_catalog   timestamp[]     type         root     ALL             false
defaultdb      pg_catalog   name[]          type         root     ALL             false
defaultdb      pg_catalog   date            type         root     ALL             false
defaultdb      pg_catalog   int4            type         root     ALL             false
defaultdb      pg_catalog   decimal         type         root     ALL             false
defaultdb      pg_catalog   timestamp       type         root     ALL             false
defaultdb      pg_catalog   uuid[]          type         root     ALL             false
defaultdb      pg_catalog   bit[]           type         root     ALL             false
defaultdb      pg_catalog   unknown         type         root     ALL             false
defaultdb      pg_catalog   float4[]        type         root     ALL             false
defaultdb      pg_catalog   bit             type         root     ALL             false
defaultdb      pg_catalog   bytes           type         root     ALL             false
defaultdb      pg_catalog   float4          type         root     ALL             false
defaultdb      pg_catalog   time            type         root     ALL             false
defaultdb      pg_catalog   void            type         root     ALL             false
defaultdb      pg_catalog   pg_lsn[]        type         root     ALL             false
defaultdb      pg_catalog   regclass[]      type         root     ALL             false
defaultdb      pg_catalog   "char"[]        type         root     ALL             false
defaultdb      pg_catalog   interval        type         root     ALL             false
defaultdb      pg_catalog   refcursor       type         root     ALL             false
defaultdb      pg_catalog   regtype         type         root     ALL             false
defaultdb      pg_catalog   oid[]           type         root     ALL             false
defaultdb      pg_catalog   interval[]      type         root     ALL             false
defaultdb      pg_catalog   varbit[]        type         root     ALL             false
defaultdb      pg_catalog   regnamespace[]  type         root     ALL             false
defaultdb      pg_catalog   timetz          type         root     ALL             false
defaultdb      pg_catalog   regtype[]       type         root     ALL             false
defaultdb      pg_catalog   int[]           type         root     ALL             false
defaultdb      pg_catalog   refcursor[]     type         root     ALL             false
defaultdb      pg_catalog   int2vector      type         root     ALL             false
defaultdb      pg_catalog   jsonb           type         root     ALL             false
defaultdb      pg_catalog   bpchar[]        type         root     ALL             false
defaultdb      pg_catalog   oid             type         root     ALL             false
defaultdb      pg_catalog   timestamptz     type         root     ALL             false
defaultdb      pg_catalog   vector          type         root     ALL             false
defaultdb      pg_catalog   decimal[]       type         root     ALL             false
defaultdb      pg_catalog   oidvector[]     type         root     ALL             false
defaultdb      pg_catalog   vector[]        type         root     ALL             false
defaultdb      pg_catalog   anyelement      type         root     ALL             false
defaultdb      pg_catalog   inet            type         root     ALL             false
defaultdb      pg_catalog   bool[]          type         root     ALL             false
defaultdb      pg_catalog   varbit          type         root     ALL             false
defaultdb      pg_catalog   geometry[]      type         root     ALL             false
defaultdb      pg_catalog   inet[]          type         root     ALL             false
defaultdb      pg_catalog   int2vector[]    type         root     ALL             false
defaultdb      pg_catalog   bytes[]         type         root     ALL             false
defaultdb      pg_catalog   oidvector       type         root     ALL             false
defaultdb      pg_catalog   regclass        type         root     ALL             false
defaultdb      pg_catalog   trigger         type         root     ALL             false
defaultdb      pg_catalog   geography       type         root     ALL             false
defaultdb      pg_catalog   string[]        type         root     ALL             false
defaultdb      pg_catalog   timetz[]        type         root     ALL             false
defaultdb      pg_catalog   tsquery[]       type         root     ALL             false
defaultdb      pg_catalog   regrole         type         root     ALL             false
defaultdb      pg_catalog   tsquery         type         root     ALL             false
defaultdb      pg_catalog   uuid            type         root     ALL             false
defaultdb      pg_catalog   geography[]     type         root     ALL             false
defaultdb      pg_catalog   record[]        type         root     ALL             false
defaultdb      pg_catalog   varchar[]       type         root     ALL             false
defaultdb      pg_catalog   bpchar          type         root     ALL             false
defaultdb      pg_catalog   int2[]          type         root     ALL             false
defaultdb      pg_catalog   timestamptz[]   type         root     ALL             false
defaultdb      pg_catalog   int2            type         root     ALL             false
defaultdb      pg_catalog   record          type         root     ALL             false
defaultdb      pg_catalog   string          type         root     ALL             false
defaultdb      pg_catalog   tsvector        type         root     ALL             false
defaultdb      pg_catalog   regrole[]       type         root     ALL             false
defaultdb      pg_catalog   bool            type         root     ALL             false
defaultdb      pg_catalog   "char"          type         root     ALL             false
defaultdb      pg_catalog   float           type         root     ALL             false
postgres       pg_catalog   timestamp       type         root     ALL             false
postgres       pg_catalog   uuid[]          type         root     ALL             false
postgres       pg_catalog   bit[]           type         root     ALL             false
postgres       pg_catalog   float4[]        type         root     ALL             false
postgres       pg_catalog   bit             type         root     ALL             false
postgres       pg_catalog   bytes           type         root     ALL             false
postgres       pg_catalog   float4          type         root     ALL             false
postgres       pg_catalog   unknown         type         root     ALL             false
postgres       pg_catalog   void            type         root     ALL             false
postgres       pg_catalog   pg_lsn[]        type         root     ALL             false
postgres       pg_catalog   regclass[]      type         root     ALL             false
postgres       pg_catalog   "char"[]        type         root     ALL             false
postgres       pg_catalog   interval        type         root     ALL             false
postgres       pg_catalog   refcursor       type         root     ALL             false
postgres       pg_catalog   regtype         type         root     ALL             false
postgres       pg_catalog   time            type         root     ALL             false
postgres       pg_catalog   oid[]           type         root     ALL             false
postgres       pg_catalog   varbit[]        type         root     ALL             false
postgres       pg_catalog   regnamespace[]  type         root     ALL             false
postgres       pg_catalog   timetz          type         root     ALL             false
postgres       pg_catalog   regtype[]       type         root     ALL             false
postgres       pg_catalog   int[]           type         root     ALL             false
postgres       pg_catalog   interval[]      type         root     ALL             false
postgres       pg_catalog   int2vector      type         root     ALL             false
postgres       pg_catalog   jsonb           type         root     ALL             false
postgres       pg_catalog   bpchar[]        type         root     ALL             false
postgres       pg_catalog   refcursor[]     type         root     ALL             false
postgres       pg_catalog   oid             type         root     ALL             false
postgres       pg_catalog   timestamptz     type         root     ALL             false
postgres       pg_catalog   vector          type         root     ALL             false
postgres       pg_catalog   oidvector[]     type         root     ALL             false
postgres       pg_catalog   vector[]        type         root     ALL             false
postgres       pg_catalog   anyelement      type         root     ALL             false
postgres       pg_catalog   inet            type         root     ALL             false
postgres       pg_catalog   bool[]          type         root     ALL             false
postgres       pg_catalog   decimal[]       type         root     ALL             false
postgres       pg_catalog   geometry[]      type         root     ALL             false
postgres       pg_catalog   inet[]          type         root     ALL             false
postgres       pg_catalog   int2vector[]    type         root     ALL             false
postgres       pg_catalog   bytes[]         type         root     ALL             false
postgres       pg_catalog   oidvector       type         root     ALL             false
postgres       pg_catalog   regclass        type         root     ALL             false
postgres       pg_catalog   trigger         type         root     ALL             false
postgres       pg_catalog   varbit          type         root     ALL             false
postgres       pg_catalog   string[]        type         root     ALL             false
postgres       pg_catalog   timetz[]        type         root     ALL             false
postgres       pg_catalog   tsquery[]       type         root     ALL             false
postgres       pg_catalog   regrole         type         root     ALL             false
postgres       pg_catalog   tsquery         type         root     ALL             false
postgres       pg_catalog   uuid            type         root     ALL             false
postgres       pg_catalog   geography       type         root     ALL             false
postgres       pg_catalog   record[]        type         root     ALL             false
postgres       pg_catalog   varchar[]       type         root     ALL             false
postgres       pg_catalog   bpchar          type         root     ALL             false
postgres       pg_catalog   int2[]          type         root     ALL             false
postgres       pg_catalog   timestamptz[]   type         root     ALL             false
postgres       pg_catalog   geography[]     type         root     ALL             false
postgres       pg_catalog   record          type         root     ALL             false
postgres       pg_catalog   string          type         root     ALL             false
postgres       pg_catalog   tsvector        type         root     ALL             false
postgres       pg_catalog   regrole[]       type         root     ALL             false
postgres       pg_catalog   bool            type         root     ALL             false
postgres       pg_catalog   "char"          type         root     ALL             false
postgres       pg_catalog   float           type         root     ALL             false
postgres       pg_catalog   int2            type         root     ALL             false
postgres       pg_catalog   date[]          type         root     ALL             false
postgres       pg_catalog   int             type         root     ALL             false
postgres       pg_catalog   int4[]          type         root     ALL             false
postgres       pg_catalog   float[]         type         root     ALL             false
postgres       pg_catalog   jsonb[]         type         root     ALL             false
postgres       pg_catalog   tsvector[]      type         root     ALL             false
postgres       pg_catalog   regprocedure[]  type         root     ALL             false
postgres       pg_catalog   name            type         root     ALL             false
postgres       pg_catalog   varchar         type         root     ALL             false
postgres       pg_catalog   geometry        type         root     ALL             false
postgres       pg_catalog   box2d[]         type         root     ALL             false
postgres       pg_catalog   box2d           type         root     ALL             false
postgres       pg_catalog   anyarray        type         root     ALL             false
postgres       pg_catalog   pg_lsn          type         root     ALL             false
postgres       pg_catalog   regprocedure    type         root     ALL             false
postgres       pg_catalog   time[]          type         root     ALL             false
postgres       pg_catalog   regproc[]       type         root     ALL             false
postgres       pg_catalog   regproc         type         root     ALL             false
postgres       pg_catalog   timestamp[]     type         root     ALL             false
postgres       pg_catalog   name[]          type         root     ALL             false
postgres       pg_catalog   date            type         root     ALL             false
postgres       pg_catalog   int4            type         root     ALL             false
postgres       pg_catalog   decimal         type         root     ALL             false
postgres       pg_catalog   regnamespace    type         root     ALL             false
test           pg_catalog   varchar[]       type         root     ALL             false
test           pg_catalog   bpchar          type         root     ALL             false
test           pg_catalog   int2[]          type         root     ALL             false
test           pg_catalog   timestamptz[]   type         root     ALL             false
test           pg_catalog   geography[]     type         root     ALL             false
test           pg_catalog   record[]        type         root     ALL             false
test           pg_catalog   string          type         root     ALL             false
test           pg_catalog   tsvector        type         root     ALL             false
test           pg_catalog   regrole[]       type         root     ALL             false
test           pg_catalog   bool            type         root     ALL             false
test           pg_catalog   "char"          type         root     ALL             false
test           pg_catalog   float           type         root     ALL             false
test           pg_catalog   int2            type         root     ALL             false
test           pg_catalog   record          type         root     ALL             false
test           pg_catalog   int             type         root     ALL             false
test           pg_catalog   int4[]          type         root     ALL             false
test           pg_catalog   float[]         type         root     ALL             false
test           pg_catalog   jsonb[]         type         root     ALL             false
test           pg_catalog   date[]          type         root     ALL             false
test           pg_catalog   regprocedure[]  type         root     ALL             false
test           pg_catalog   name            type         root     ALL             false
test           pg_catalog   varchar         type         root     ALL             false
test           pg_catalog   geometry        type         root     ALL             false
test           pg_catalog   box2d[]         type         root     ALL             false
test           pg_catalog   tsvector[]      type         root     ALL             false
test           pg_catalog   box2d           type         root     ALL             false
test           pg_catalog   anyarray        type         root     ALL             false
test           pg_catalog   pg_lsn          type         root     ALL             false
test           pg_catalog   regprocedure    type         root     ALL             false
test           pg_catalog   time[]          type         root     ALL             false
test           pg_catalog   regproc[]       type         root     ALL             false
test           pg_catalog   timestamp[]     type         root     ALL             false
test           pg_catalog   name[]          type         root     ALL             false
test           pg_catalog   date            type         root     ALL             false
test           pg_catalog   int4            type         root     ALL             false
test           pg_catalog   decimal         type         root     ALL             false
test           pg_catalog   regnamespace    type         root     ALL             false
test           pg_catalog   regproc         type         root     ALL             false
test           pg_catalog   timestamp       type         root     ALL             false
test           pg_catalog   uuid[]          type         root     ALL             false
test           pg_catalog   bit[]           type         root     ALL             false
test           pg_catalog   bit             type         root     ALL             false
test           pg_catalog   bytes           type         root     ALL             false
test           pg_catalog   float4          type         root     ALL             false
test           pg_catalog   unknown         type         root     ALL             false
test           pg_catalog   float4[]        type         root     ALL             false
test           pg_catalog   pg_lsn[]        type         root     ALL             false
test           pg_catalog   regclass[]      type         root     ALL             false
test           pg_catalog   "char"[]        type         root     ALL             false
test           pg_catalog   interval        type         root     ALL             false
test           pg_catalog   refcursor       type         root     ALL             false
test           pg_catalog   regtype         type         root     ALL             false
test           pg_catalog   time            type         root     ALL             false
test           pg_catalog   void            type         root     ALL             false
test           pg_catalog   oid[]           type         root     ALL             false
test           pg_catalog   regnamespace[]  type         root     ALL             false
test           pg_catalog   timetz          type         root     ALL             false
test           pg_catalog   regtype[]       type         root     ALL             false
test           pg_catalog   int[]           type         root     ALL             false
test           pg_catalog   interval[]      type         root     ALL             false
test           pg_catalog   varbit[]        type         root     ALL             false
test           pg_catalog   int2vector      type         root     ALL             false
test           pg_catalog   jsonb           type         root     ALL             false
test           pg_catalog   bpchar[]        type         root     ALL             false
test           pg_catalog   refcursor[]     type         root     ALL             false
test           pg_catalog   oid             type         root     ALL             false
test           pg_catalog   timestamptz     type         root     ALL             false
test           pg_catalog   vector          type         root     ALL             false
test           pg_catalog   vector[]        type         root     ALL             false
test           pg_catalog   anyelement      type         root     ALL             false
test           pg_catalog   inet            type         root     ALL             false
test           pg_catalog   bool[]          type         root     ALL             false
test           pg_catalog   decimal[]       type         root     ALL             false
test           pg_catalog   oidvector[]     type         root     ALL             false
test           pg_catalog   inet[]          type         root     ALL             false
test           pg_catalog   int2vector[]    type         root     ALL             false
test           pg_catalog   bytes[]         type         root     ALL             false
test           pg_catalog   oidvector       type         root     ALL             false
test           pg_catalog   regclass        type         root     ALL             false
test           pg_catalog   trigger         type         root     ALL             false
test           pg_catalog   varbit          type         root     ALL             false
test           pg_catalog   geometry[]      type         root     ALL             false
test           pg_catalog   timetz[]        type         root     ALL             false
test           pg_catalog   tsquery[]       type         root     ALL             false
test           pg_catalog   regrole         type         root     ALL             false
test           pg_catalog   tsquery         type         root     ALL             false
test           pg_catalog   uuid            type         root     ALL             false
test           pg_catalog   geography       type         root     ALL             false
test           pg_catalog   string[]        type         root     ALL             false
a              public       NULL            schema       public   CREATE          false
a              public       NULL            schema       public   USAGE           false
defaultdb      public       NULL            schema       public   CREATE          false
defaultdb      public       NULL            schema       public   USAGE           false
postgres       public       NULL            schema       public   CREATE          false
postgres       public       NULL            schema       public   USAGE           false
test           public       NULL            schema       public   CREATE          false
test           public       NULL            schema       public   USAGE           false


statement error pgcode 42P01 relation "a.t" does not exist
SHOW GRANTS ON a.t

statement error pgcode 42P01 relation "t" does not exist
SHOW GRANTS ON t

statement ok
SET DATABASE = a

statement error pgcode 42P01 relation "t" does not exist
SHOW GRANTS ON t

statement error pgcode 42P01 relation "a.t" does not exist
GRANT ALL ON a.t TO readwrite

statement ok
CREATE TABLE t (id INT PRIMARY KEY)

query TTTTTB colnames,rowsort
SHOW GRANTS ON t
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
a              public       t           admin    ALL             true
a              public       t           root     ALL             true

query TTTTTB colnames,rowsort
SHOW GRANTS ON a.t
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
a              public       t           admin    ALL             true
a              public       t           root     ALL             true

statement ok
CREATE USER "test-user"

statement ok
GRANT ALL ON t TO readwrite, "test-user"

query TTTTTB rowsort
SHOW GRANTS ON t
----
a  public  t  admin      ALL  true
a  public  t  readwrite  ALL  false
a  public  t  root       ALL  true
a  public  t  test-user  ALL  false

query TTTTTB rowsort
SHOW GRANTS ON t FOR readwrite, "test-user"
----
a  public  t  readwrite  ALL  false
a  public  t  test-user  ALL  false

statement ok
REVOKE INSERT,DELETE ON t FROM "test-user",readwrite

query TTTTTB rowsort
SHOW GRANTS ON t
----
a  public  t  admin      ALL         true
a  public  t  readwrite  BACKUP      false
a  public  t  readwrite  CHANGEFEED  false
a  public  t  readwrite  CREATE      false
a  public  t  readwrite  DROP        false
a  public  t  readwrite  SELECT      false
a  public  t  readwrite  TRIGGER     false
a  public  t  readwrite  UPDATE      false
a  public  t  readwrite  ZONECONFIG  false
a  public  t  root       ALL         true
a  public  t  test-user  BACKUP      false
a  public  t  test-user  CHANGEFEED  false
a  public  t  test-user  CREATE      false
a  public  t  test-user  DROP        false
a  public  t  test-user  SELECT      false
a  public  t  test-user  TRIGGER     false
a  public  t  test-user  UPDATE      false
a  public  t  test-user  ZONECONFIG  false

query TTTTTB rowsort
SHOW GRANTS ON t FOR readwrite, "test-user"
----
a  public  t  readwrite  BACKUP      false
a  public  t  readwrite  CHANGEFEED  false
a  public  t  readwrite  CREATE      false
a  public  t  readwrite  DROP        false
a  public  t  readwrite  SELECT      false
a  public  t  readwrite  TRIGGER     false
a  public  t  readwrite  UPDATE      false
a  public  t  readwrite  ZONECONFIG  false
a  public  t  test-user  BACKUP      false
a  public  t  test-user  CHANGEFEED  false
a  public  t  test-user  CREATE      false
a  public  t  test-user  DROP        false
a  public  t  test-user  SELECT      false
a  public  t  test-user  TRIGGER     false
a  public  t  test-user  UPDATE      false
a  public  t  test-user  ZONECONFIG  false

statement ok rowsort
REVOKE SELECT ON t FROM "test-user"

query TTTTTB rowsort
SHOW GRANTS ON t
----
a  public  t  admin      ALL         true
a  public  t  readwrite  BACKUP      false
a  public  t  readwrite  CHANGEFEED  false
a  public  t  readwrite  CREATE      false
a  public  t  readwrite  DROP        false
a  public  t  readwrite  SELECT      false
a  public  t  readwrite  TRIGGER     false
a  public  t  readwrite  UPDATE      false
a  public  t  readwrite  ZONECONFIG  false
a  public  t  root       ALL         true
a  public  t  test-user  BACKUP      false
a  public  t  test-user  CHANGEFEED  false
a  public  t  test-user  CREATE      false
a  public  t  test-user  DROP        false
a  public  t  test-user  TRIGGER     false
a  public  t  test-user  UPDATE      false
a  public  t  test-user  ZONECONFIG  false

query TTTTTB rowsort
SHOW GRANTS ON t FOR readwrite, "test-user"
----
a  public  t  readwrite  BACKUP      false
a  public  t  readwrite  CHANGEFEED  false
a  public  t  readwrite  CREATE      false
a  public  t  readwrite  DROP        false
a  public  t  readwrite  SELECT      false
a  public  t  readwrite  TRIGGER     false
a  public  t  readwrite  UPDATE      false
a  public  t  readwrite  ZONECONFIG  false
a  public  t  test-user  BACKUP      false
a  public  t  test-user  CHANGEFEED  false
a  public  t  test-user  CREATE      false
a  public  t  test-user  DROP        false
a  public  t  test-user  TRIGGER     false
a  public  t  test-user  UPDATE      false
a  public  t  test-user  ZONECONFIG  false

statement ok
REVOKE ALL ON t FROM readwrite,"test-user"

query TTTTTB rowsort
SHOW GRANTS ON t
----
a  public  t  admin  ALL  true
a  public  t  root   ALL  true

query TTTTTB
SHOW GRANTS ON t FOR readwrite, "test-user"
----

# The same as above, but on a view

statement ok
CREATE VIEW v as SELECT id FROM t

query TTTTTB colnames,rowsort
SHOW GRANTS ON v
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
a              public       v           admin    ALL             true
a              public       v           root     ALL             true

query TTTTTB colnames,rowsort
SHOW GRANTS ON a.v
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
a              public       v           admin    ALL             true
a              public       v           root     ALL             true

statement ok
GRANT ALL ON v TO readwrite, "test-user"

query TTTTTB rowsort
SHOW GRANTS ON v
----
a  public  v  admin      ALL  true
a  public  v  readwrite  ALL  false
a  public  v  root       ALL  true
a  public  v  test-user  ALL  false

query TTTTTB rowsort
SHOW GRANTS ON v FOR readwrite, "test-user"
----
a  public  v  readwrite  ALL  false
a  public  v  test-user  ALL  false

statement ok
REVOKE INSERT,DELETE ON v FROM "test-user",readwrite

query TTTTTB rowsort
SHOW GRANTS ON v
----
a  public  v  admin      ALL         true
a  public  v  readwrite  BACKUP      false
a  public  v  readwrite  CHANGEFEED  false
a  public  v  readwrite  CREATE      false
a  public  v  readwrite  DROP        false
a  public  v  readwrite  SELECT      false
a  public  v  readwrite  TRIGGER     false
a  public  v  readwrite  UPDATE      false
a  public  v  readwrite  ZONECONFIG  false
a  public  v  root       ALL         true
a  public  v  test-user  BACKUP      false
a  public  v  test-user  CHANGEFEED  false
a  public  v  test-user  CREATE      false
a  public  v  test-user  DROP        false
a  public  v  test-user  SELECT      false
a  public  v  test-user  TRIGGER     false
a  public  v  test-user  UPDATE      false
a  public  v  test-user  ZONECONFIG  false

query TTTTTB rowsort
SHOW GRANTS ON v FOR readwrite, "test-user"
----
a  public  v  readwrite  BACKUP      false
a  public  v  readwrite  CHANGEFEED  false
a  public  v  readwrite  CREATE      false
a  public  v  readwrite  DROP        false
a  public  v  readwrite  SELECT      false
a  public  v  readwrite  TRIGGER     false
a  public  v  readwrite  UPDATE      false
a  public  v  readwrite  ZONECONFIG  false
a  public  v  test-user  BACKUP      false
a  public  v  test-user  CHANGEFEED  false
a  public  v  test-user  CREATE      false
a  public  v  test-user  DROP        false
a  public  v  test-user  SELECT      false
a  public  v  test-user  TRIGGER     false
a  public  v  test-user  UPDATE      false
a  public  v  test-user  ZONECONFIG  false

statement ok
REVOKE SELECT ON v FROM "test-user"

query TTTTTB rowsort
SHOW GRANTS ON v
----
a  public  v  admin      ALL         true
a  public  v  readwrite  BACKUP      false
a  public  v  readwrite  CHANGEFEED  false
a  public  v  readwrite  CREATE      false
a  public  v  readwrite  DROP        false
a  public  v  readwrite  SELECT      false
a  public  v  readwrite  TRIGGER     false
a  public  v  readwrite  UPDATE      false
a  public  v  readwrite  ZONECONFIG  false
a  public  v  root       ALL         true
a  public  v  test-user  BACKUP      false
a  public  v  test-user  CHANGEFEED  false
a  public  v  test-user  CREATE      false
a  public  v  test-user  DROP        false
a  public  v  test-user  TRIGGER     false
a  public  v  test-user  UPDATE      false
a  public  v  test-user  ZONECONFIG  false

query TTTTTB rowsort
SHOW GRANTS ON v FOR readwrite, "test-user"
----
a  public  v  readwrite  BACKUP      false
a  public  v  readwrite  CHANGEFEED  false
a  public  v  readwrite  CREATE      false
a  public  v  readwrite  DROP        false
a  public  v  readwrite  SELECT      false
a  public  v  readwrite  TRIGGER     false
a  public  v  readwrite  UPDATE      false
a  public  v  readwrite  ZONECONFIG  false
a  public  v  test-user  BACKUP      false
a  public  v  test-user  CHANGEFEED  false
a  public  v  test-user  CREATE      false
a  public  v  test-user  DROP        false
a  public  v  test-user  TRIGGER     false
a  public  v  test-user  UPDATE      false
a  public  v  test-user  ZONECONFIG  false

query TTTTTTB rowsort
SHOW GRANTS FOR readwrite, "test-user"
----
a  NULL    NULL  database  readwrite  ALL         false
a  public  NULL  schema    public     CREATE      false
a  public  NULL  schema    public     USAGE       false
a  public  v     table     readwrite  BACKUP      false
a  public  v     table     readwrite  CHANGEFEED  false
a  public  v     table     readwrite  CREATE      false
a  public  v     table     readwrite  DROP        false
a  public  v     table     readwrite  SELECT      false
a  public  v     table     readwrite  TRIGGER     false
a  public  v     table     readwrite  UPDATE      false
a  public  v     table     readwrite  ZONECONFIG  false
a  public  v     table     test-user  BACKUP      false
a  public  v     table     test-user  CHANGEFEED  false
a  public  v     table     test-user  CREATE      false
a  public  v     table     test-user  DROP        false
a  public  v     table     test-user  TRIGGER     false
a  public  v     table     test-user  UPDATE      false
a  public  v     table     test-user  ZONECONFIG  false

statement ok
REVOKE ALL ON v FROM readwrite,"test-user"

query TTTTTB rowsort
SHOW GRANTS ON v
----
a  public  v  admin  ALL  true
a  public  v  root   ALL  true

query TTTTTB rowsort
SHOW GRANTS ON v FOR readwrite, "test-user"
----

query TTTTTTB rowsort
SHOW GRANTS FOR readwrite, "test-user"
----
a  NULL    NULL  database  readwrite  ALL     false
a  public  NULL  schema    public     CREATE  false
a  public  NULL  schema    public     USAGE   false

# Verify that the DB privileges have not changed.
query TTTB colnames,rowsort
SHOW GRANTS ON DATABASE a
----
database_name  grantee    privilege_type  is_grantable
a              admin      ALL             true
a              public     CONNECT         false
a              readwrite  ALL             false
a              root       ALL             true


# Errors due to invalid targets.
statement ok
SET DATABASE = ""

statement error at or near "@": syntax error
GRANT ALL ON a.t@xyz TO readwrite

statement error no database or schema specified
GRANT ALL ON * TO readwrite

statement error pgcode 42P01 relation "a.tt" does not exist
GRANT ALL ON a.t, a.tt TO readwrite

# '*' doesn't work for databases.
statement error at or near "\*": syntax error
GRANT ALL ON DATABASE * TO readwrite

statement ok
CREATE DATABASE b

statement ok
CREATE TABLE b.t (id INT PRIMARY KEY)

statement ok
CREATE TABLE b.t2 (id INT PRIMARY KEY)

statement ok
CREATE DATABASE c

statement ok
CREATE TABLE c.t (id INT PRIMARY KEY)

# `*` works after you've set a database
statement ok
SET DATABASE = "b"

statement error pgcode 42704 role/user "vanilli" does not exist
GRANT ALL ON * TO Vanilli

statement ok
CREATE USER Vanilli

statement ok
GRANT ALL ON * TO Vanilli

query TTTTTB colnames,rowsort
SHOW GRANTS ON *
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
b              public       t           admin    ALL             true
b              public       t           root     ALL             true
b              public       t           vanilli  ALL             false
b              public       t2          admin    ALL             true
b              public       t2          root     ALL             true
b              public       t2          vanilli  ALL             false


# Multiple targets.
statement ok
CREATE USER Millie

statement ok
GRANT ALL ON c.*, b.t TO Millie

query TTTTTB colnames,rowsort
SHOW GRANTS ON b.*
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
b              public       t           admin    ALL             true
b              public       t           millie   ALL             false
b              public       t           root     ALL             true
b              public       t           vanilli  ALL             false
b              public       t2          admin    ALL             true
b              public       t2          root     ALL             true
b              public       t2          vanilli  ALL             false

query TTTTTB colnames,rowsort
SHOW GRANTS ON a.*, b.*
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
a              public       t           admin    ALL             true
a              public       t           root     ALL             true
a              public       v           admin    ALL             true
a              public       v           root     ALL             true
b              public       t           admin    ALL             true
b              public       t           millie   ALL             false
b              public       t           root     ALL             true
b              public       t           vanilli  ALL             false
b              public       t2          admin    ALL             true
b              public       t2          root     ALL             true
b              public       t2          vanilli  ALL             false

query TTTTTB colnames,rowsort
SHOW GRANTS ON c.t
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
c              public       t           admin    ALL             true
c              public       t           millie   ALL             false
c              public       t           root     ALL             true

statement ok
REVOKE ALL ON *, c.* FROM Vanilli

query TTTTTB colnames,rowsort
SHOW GRANTS ON b.*
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
b              public       t           admin    ALL             true
b              public       t           millie   ALL             false
b              public       t           root     ALL             true
b              public       t2          admin    ALL             true
b              public       t2          root     ALL             true

statement ok
CREATE DATABASE empty

query TTTTTB colnames,rowsort
SHOW GRANTS ON empty.*
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable

query TTTTTB colnames,rowsort
SHOW GRANTS ON empty.*, b.*
----
database_name  schema_name  table_name  grantee  privilege_type  is_grantable
b              public       t           admin    ALL             true
b              public       t           millie   ALL             false
b              public       t           root     ALL             true
b              public       t2          admin    ALL             true
b              public       t2          root     ALL             true

# Usage privilege should not be grantable on tables.

statement error pq: invalid privilege type USAGE for table
GRANT USAGE ON t TO testuser

# Grant / Revoke should not work on system tables.

statement error pq: cannot GRANT on system object
GRANT SELECT ON system.lease TO testuser

statement error pq: cannot REVOKE on system object
REVOKE SELECT ON system.lease FROM testuser

# Postgres does a no-op here, but since the RULE privilege is very legacy,
# we error explicitly instead of getting 100% compatibility.
statement error invalid privilege type RULE for table
GRANT RULE ON t TO testuser

# This glob expands to no tables, that should be fine and should return the
# correct errors.
statement error pgcode 42704 no object matched
GRANT SELECT ON TABLE empty.* TO testuser;

statement ok
create schema empty.sc

statement error pgcode 42704 no object matched
GRANT SELECT ON TABLE empty.sc.* TO testuser;

# Add a test to ensure that when you mix virtual and physical tables in a grant
# that you get the error we
subtest mixed_virtual_physical

statement ok
CREATE DATABASE db;
USE db;
CREATE TABLE t (i INT);

statement error pgcode 0A000 cannot mix grants between virtual and non-virtual tables
GRANT SELECT ON TABLE t, crdb_internal.tables TO testuser;

statement error pgcode 0A000 cannot mix grants between virtual and non-virtual tables
GRANT SELECT ON TABLE crdb_internal.tables, t TO testuser;

statement ok
CREATE USER ROACH;
CREATE TABLE table1 (count INT);
CREATE TABLE table2 (count INT);
BEGIN;
GRANT ALL ON table1 TO ROACH;
GRANT ALL ON table2 TO ROACH;
COMMIT;

query T rowsort
select description from [show jobs] where description LIKE '%updating privileges for table%';
----

query TTTTTTB colnames,rowsort
SHOW GRANTS FOR roach
----
database_name  schema_name  object_name  object_type  grantee  privilege_type  is_grantable
db             public       NULL         schema       public   CREATE          false
db             public       NULL         schema       public   USAGE           false
db             public       table1       table        roach    ALL             false
db             public       table2       table        roach    ALL             false
