# 3node-tenant is blocked from running this file because of the absence of
# the tenant table for tenants. Legacy schema changer is also skipped, because
# some of the queries relating internal state will be impacted in terms of
# descriptor versions, etc..
# LogicTest: !3node-tenant-default-configs !local-legacy-schema-changer

# Verify information_schema database handles mutation statements correctly.

query error database "information_schema" does not exist
ALTER DATABASE information_schema RENAME TO not_information_schema

statement error schema cannot be modified: "information_schema"
CREATE TABLE information_schema.t (x INT)

query error database "information_schema" does not exist
DROP DATABASE information_schema

query TTTTIT rowsort
SHOW TABLES FROM information_schema
----
information_schema  administrable_role_authorizations      table  node  NULL  NULL
information_schema  applicable_roles                       table  node  NULL  NULL
information_schema  attributes                             view   node  NULL  NULL
information_schema  character_sets                         table  node  NULL  NULL
information_schema  check_constraint_routine_usage         table  node  NULL  NULL
information_schema  check_constraints                      table  node  NULL  NULL
information_schema  collation_character_set_applicability  table  node  NULL  NULL
information_schema  collations                             table  node  NULL  NULL
information_schema  column_column_usage                    table  node  NULL  NULL
information_schema  column_domain_usage                    table  node  NULL  NULL
information_schema  column_options                         table  node  NULL  NULL
information_schema  column_privileges                      table  node  NULL  NULL
information_schema  column_statistics                      table  node  NULL  NULL
information_schema  column_udt_usage                       table  node  NULL  NULL
information_schema  columns                                table  node  NULL  NULL
information_schema  columns_extensions                     table  node  NULL  NULL
information_schema  constraint_column_usage                table  node  NULL  NULL
information_schema  constraint_table_usage                 table  node  NULL  NULL
information_schema  data_type_privileges                   table  node  NULL  NULL
information_schema  domain_constraints                     table  node  NULL  NULL
information_schema  domain_udt_usage                       table  node  NULL  NULL
information_schema  domains                                table  node  NULL  NULL
information_schema  element_types                          table  node  NULL  NULL
information_schema  enabled_roles                          table  node  NULL  NULL
information_schema  engines                                table  node  NULL  NULL
information_schema  events                                 table  node  NULL  NULL
information_schema  files                                  table  node  NULL  NULL
information_schema  foreign_data_wrapper_options           table  node  NULL  NULL
information_schema  foreign_data_wrappers                  table  node  NULL  NULL
information_schema  foreign_server_options                 table  node  NULL  NULL
information_schema  foreign_servers                        table  node  NULL  NULL
information_schema  foreign_table_options                  table  node  NULL  NULL
information_schema  foreign_tables                         table  node  NULL  NULL
information_schema  information_schema_catalog_name        table  node  NULL  NULL
information_schema  key_column_usage                       table  node  NULL  NULL
information_schema  keywords                               table  node  NULL  NULL
information_schema  optimizer_trace                        table  node  NULL  NULL
information_schema  parameters                             view   node  NULL  NULL
information_schema  partitions                             table  node  NULL  NULL
information_schema  plugins                                table  node  NULL  NULL
information_schema  processlist                            table  node  NULL  NULL
information_schema  profiling                              table  node  NULL  NULL
information_schema  referential_constraints                table  node  NULL  NULL
information_schema  resource_groups                        table  node  NULL  NULL
information_schema  role_column_grants                     table  node  NULL  NULL
information_schema  role_routine_grants                    table  node  NULL  NULL
information_schema  role_table_grants                      table  node  NULL  NULL
information_schema  role_udt_grants                        table  node  NULL  NULL
information_schema  role_usage_grants                      table  node  NULL  NULL
information_schema  routine_privileges                     table  node  NULL  NULL
information_schema  routines                               view   node  NULL  NULL
information_schema  schema_privileges                      table  node  NULL  NULL
information_schema  schemata                               table  node  NULL  NULL
information_schema  schemata_extensions                    table  node  NULL  NULL
information_schema  sequences                              table  node  NULL  NULL
information_schema  session_variables                      table  node  NULL  NULL
information_schema  sql_features                           table  node  NULL  NULL
information_schema  sql_implementation_info                table  node  NULL  NULL
information_schema  sql_parts                              table  node  NULL  NULL
information_schema  sql_sizing                             table  node  NULL  NULL
information_schema  st_geometry_columns                    table  node  NULL  NULL
information_schema  st_spatial_reference_systems           table  node  NULL  NULL
information_schema  st_units_of_measure                    table  node  NULL  NULL
information_schema  statistics                             table  node  NULL  NULL
information_schema  table_constraints                      table  node  NULL  NULL
information_schema  table_constraints_extensions           table  node  NULL  NULL
information_schema  table_privileges                       table  node  NULL  NULL
information_schema  tables                                 table  node  NULL  NULL
information_schema  tables_extensions                      table  node  NULL  NULL
information_schema  tablespaces                            table  node  NULL  NULL
information_schema  tablespaces_extensions                 table  node  NULL  NULL
information_schema  transforms                             table  node  NULL  NULL
information_schema  triggered_update_columns               table  node  NULL  NULL
information_schema  triggers                               table  node  NULL  NULL
information_schema  type_privileges                        table  node  NULL  NULL
information_schema  udt_privileges                         table  node  NULL  NULL
information_schema  usage_privileges                       table  node  NULL  NULL
information_schema  user_attributes                        table  node  NULL  NULL
information_schema  user_defined_types                     view   node  NULL  NULL
information_schema  user_mapping_options                   table  node  NULL  NULL
information_schema  user_mappings                          table  node  NULL  NULL
information_schema  user_privileges                        table  node  NULL  NULL
information_schema  view_column_usage                      table  node  NULL  NULL
information_schema  view_routine_usage                     table  node  NULL  NULL
information_schema  view_table_usage                       table  node  NULL  NULL
information_schema  views                                  table  node  NULL  NULL

# Verify that the name is not special for databases.

statement ok
CREATE DATABASE other_db

statement ok
ALTER DATABASE other_db RENAME TO information_schema

statement error database "information_schema" already exists
CREATE DATABASE information_schema

statement ok
DROP DATABASE information_schema CASCADE


# Verify information_schema tables handle mutation statements correctly.

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables RENAME TO information_schema.bad

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables RENAME COLUMN x TO y

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables ADD COLUMN x DECIMAL

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables DROP COLUMN x

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables ADD CONSTRAINT foo UNIQUE (b)

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables DROP CONSTRAINT bar

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables ALTER COLUMN x SET DEFAULT 'foo'

statement error tables is a virtual object and cannot be modified
ALTER TABLE information_schema.tables ALTER x DROP NOT NULL

statement error collation_character_set_applicability is a virtual object and cannot be modified
ALTER TABLE information_schema.collation_character_set_applicability ALTER x DROP NOT NULL

statement error collations is a virtual object and cannot be modified
ALTER TABLE information_schema.collations ALTER x DROP NOT NULL

statement error tables is a virtual object and cannot be modified
CREATE INDEX i on information_schema.tables (x)

statement error tables is a virtual object and cannot be modified
DROP TABLE information_schema.tables

statement error tables is a virtual object and cannot be modified
DROP INDEX information_schema.tables@i

statement error session_variables is a virtual object and cannot be modified
ALTER TABLE information_schema.session_variables ALTER x DROP NOT NULL

# Verify information_schema tables handles read-only property correctly.

query error user root does not have DELETE privilege on relation tables
DELETE FROM information_schema.tables

query error user root does not have INSERT privilege on relation tables
INSERT INTO information_schema.tables VALUES ('abc')

statement error user root does not have UPDATE privilege on relation tables
UPDATE information_schema.tables SET a = 'abc'

statement error tables is a virtual object and cannot be modified
TRUNCATE TABLE information_schema.tables

# Verify information_schema collation_character_set_applicability handles read-only property correctly.

query error user root does not have DELETE privilege on relation collation_character_set_applicability
DELETE FROM information_schema.collation_character_set_applicability

query error user root does not have INSERT privilege on relation collation_character_set_applicability
INSERT INTO information_schema.collation_character_set_applicability VALUES ('abc')

statement error user root does not have UPDATE privilege on relation collation_character_set_applicability
UPDATE information_schema.collation_character_set_applicability SET a = 'abc'

statement error collation_character_set_applicability is a virtual object and cannot be modified
TRUNCATE TABLE information_schema.collation_character_set_applicability

# Verify information_schema collations handles read-only property correctly.

query error user root does not have DELETE privilege on relation collations
DELETE FROM information_schema.collations

query error user root does not have INSERT privilege on relation collations
INSERT INTO information_schema.collations VALUES ('abc')

statement error user root does not have UPDATE privilege on relation collations
UPDATE information_schema.collations SET a = 'abc'

statement error collations is a virtual object and cannot be modified
TRUNCATE TABLE information_schema.collations

# Verify information_schema session_variables handles read-only property correctly.

query error user root does not have DELETE privilege on relation session_variables
DELETE FROM information_schema.session_variables

query error user root does not have INSERT privilege on relation session_variables
INSERT INTO information_schema.session_variables VALUES ('abc')

statement error user root does not have UPDATE privilege on relation session_variables
UPDATE information_schema.session_variables SET a = 'abc'

statement error session_variables is a virtual object and cannot be modified
TRUNCATE TABLE information_schema.session_variables

# Verify information_schema handles reflection correctly.

query TTTTTT rowsort
SHOW DATABASES
----
defaultdb  root  NULL  NULL  {}  NULL
postgres   root  NULL  NULL  {}  NULL
system     node  NULL  NULL  {}  NULL
test       root  NULL  NULL  {}  NULL

query TTTTIT rowsort
SHOW TABLES FROM test.information_schema
----
information_schema  administrable_role_authorizations      table  node  NULL  NULL
information_schema  applicable_roles                       table  node  NULL  NULL
information_schema  attributes                             view   node  NULL  NULL
information_schema  character_sets                         table  node  NULL  NULL
information_schema  check_constraint_routine_usage         table  node  NULL  NULL
information_schema  check_constraints                      table  node  NULL  NULL
information_schema  collation_character_set_applicability  table  node  NULL  NULL
information_schema  collations                             table  node  NULL  NULL
information_schema  column_column_usage                    table  node  NULL  NULL
information_schema  column_domain_usage                    table  node  NULL  NULL
information_schema  column_options                         table  node  NULL  NULL
information_schema  column_privileges                      table  node  NULL  NULL
information_schema  column_statistics                      table  node  NULL  NULL
information_schema  column_udt_usage                       table  node  NULL  NULL
information_schema  columns                                table  node  NULL  NULL
information_schema  columns_extensions                     table  node  NULL  NULL
information_schema  constraint_column_usage                table  node  NULL  NULL
information_schema  constraint_table_usage                 table  node  NULL  NULL
information_schema  data_type_privileges                   table  node  NULL  NULL
information_schema  domain_constraints                     table  node  NULL  NULL
information_schema  domain_udt_usage                       table  node  NULL  NULL
information_schema  domains                                table  node  NULL  NULL
information_schema  element_types                          table  node  NULL  NULL
information_schema  enabled_roles                          table  node  NULL  NULL
information_schema  engines                                table  node  NULL  NULL
information_schema  events                                 table  node  NULL  NULL
information_schema  files                                  table  node  NULL  NULL
information_schema  foreign_data_wrapper_options           table  node  NULL  NULL
information_schema  foreign_data_wrappers                  table  node  NULL  NULL
information_schema  foreign_server_options                 table  node  NULL  NULL
information_schema  foreign_servers                        table  node  NULL  NULL
information_schema  foreign_table_options                  table  node  NULL  NULL
information_schema  foreign_tables                         table  node  NULL  NULL
information_schema  information_schema_catalog_name        table  node  NULL  NULL
information_schema  key_column_usage                       table  node  NULL  NULL
information_schema  keywords                               table  node  NULL  NULL
information_schema  optimizer_trace                        table  node  NULL  NULL
information_schema  parameters                             view   node  NULL  NULL
information_schema  partitions                             table  node  NULL  NULL
information_schema  plugins                                table  node  NULL  NULL
information_schema  processlist                            table  node  NULL  NULL
information_schema  profiling                              table  node  NULL  NULL
information_schema  referential_constraints                table  node  NULL  NULL
information_schema  resource_groups                        table  node  NULL  NULL
information_schema  role_column_grants                     table  node  NULL  NULL
information_schema  role_routine_grants                    table  node  NULL  NULL
information_schema  role_table_grants                      table  node  NULL  NULL
information_schema  role_udt_grants                        table  node  NULL  NULL
information_schema  role_usage_grants                      table  node  NULL  NULL
information_schema  routine_privileges                     table  node  NULL  NULL
information_schema  routines                               view   node  NULL  NULL
information_schema  schema_privileges                      table  node  NULL  NULL
information_schema  schemata                               table  node  NULL  NULL
information_schema  schemata_extensions                    table  node  NULL  NULL
information_schema  sequences                              table  node  NULL  NULL
information_schema  session_variables                      table  node  NULL  NULL
information_schema  sql_features                           table  node  NULL  NULL
information_schema  sql_implementation_info                table  node  NULL  NULL
information_schema  sql_parts                              table  node  NULL  NULL
information_schema  sql_sizing                             table  node  NULL  NULL
information_schema  st_geometry_columns                    table  node  NULL  NULL
information_schema  st_spatial_reference_systems           table  node  NULL  NULL
information_schema  st_units_of_measure                    table  node  NULL  NULL
information_schema  statistics                             table  node  NULL  NULL
information_schema  table_constraints                      table  node  NULL  NULL
information_schema  table_constraints_extensions           table  node  NULL  NULL
information_schema  table_privileges                       table  node  NULL  NULL
information_schema  tables                                 table  node  NULL  NULL
information_schema  tables_extensions                      table  node  NULL  NULL
information_schema  tablespaces                            table  node  NULL  NULL
information_schema  tablespaces_extensions                 table  node  NULL  NULL
information_schema  transforms                             table  node  NULL  NULL
information_schema  triggered_update_columns               table  node  NULL  NULL
information_schema  triggers                               table  node  NULL  NULL
information_schema  type_privileges                        table  node  NULL  NULL
information_schema  udt_privileges                         table  node  NULL  NULL
information_schema  usage_privileges                       table  node  NULL  NULL
information_schema  user_attributes                        table  node  NULL  NULL
information_schema  user_defined_types                     view   node  NULL  NULL
information_schema  user_mapping_options                   table  node  NULL  NULL
information_schema  user_mappings                          table  node  NULL  NULL
information_schema  user_privileges                        table  node  NULL  NULL
information_schema  view_column_usage                      table  node  NULL  NULL
information_schema  view_routine_usage                     table  node  NULL  NULL
information_schema  view_table_usage                       table  node  NULL  NULL
information_schema  views                                  table  node  NULL  NULL

query TT colnames
SHOW CREATE TABLE information_schema.tables
----
table_name                 create_statement
information_schema.tables  CREATE TABLE information_schema.tables (
                             table_catalog STRING NOT NULL,
                             table_schema STRING NOT NULL,
                             table_name STRING NOT NULL,
                             table_type STRING NOT NULL,
                             is_insertable_into STRING NOT NULL,
                             version INT8 NULL
                           )

query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.tables
----
column_name         data_type  is_nullable  column_default  generation_expression  indices  is_hidden
table_catalog       STRING     false        NULL            ·                      {}       false
table_schema        STRING     false        NULL            ·                      {}       false
table_name          STRING     false        NULL            ·                      {}       false
table_type          STRING     false        NULL            ·                      {}       false
is_insertable_into  STRING     false        NULL            ·                      {}       false
version             INT8       true         NULL            ·                      {}       false

query TTBITTTBBBF colnames
SHOW INDEXES FROM information_schema.tables
----
table_name  index_name  non_unique  seq_in_index  column_name  definition  direction  storing  implicit  visible  visibility

query TTTTB colnames
SHOW CONSTRAINTS FROM information_schema.tables
----
table_name  constraint_name  constraint_type  details  validated

query TTTTTB colnames
SHOW GRANTS ON information_schema.tables
----
database_name  schema_name         table_name  grantee  privilege_type  is_grantable
test           information_schema  tables      public   SELECT          false


# Verify selecting from information_schema.

## information_schema.schemata

query TTTTT colnames,rowsort
SELECT * FROM information_schema.schemata
----
catalog_name  schema_name         default_character_set_name  sql_path  crdb_is_user_defined
test          crdb_internal       NULL                        NULL      NO
test          information_schema  NULL                        NULL      NO
test          pg_catalog          NULL                        NULL      NO
test          pg_extension        NULL                        NULL      NO
test          public              NULL                        NULL      YES

query TTTTT colnames,rowsort
SELECT * FROM INFormaTION_SCHEMa.schemata
----
catalog_name  schema_name         default_character_set_name  sql_path  crdb_is_user_defined
test          crdb_internal       NULL                        NULL      NO
test          information_schema  NULL                        NULL      NO
test          pg_catalog          NULL                        NULL      NO
test          pg_extension        NULL                        NULL      NO
test          public              NULL                        NULL      YES

## information_schema.tables

# Check the default contents of information_schema.tables (incl. the
# special system tables, filtered to avoid a brittle test).
query TT rowsort
select table_schema, table_name FROM information_schema.tables
WHERE (table_schema <> 'crdb_internal' OR table_name = 'node_build_info');
----
crdb_internal       node_build_info
information_schema  administrable_role_authorizations
information_schema  applicable_roles
information_schema  attributes
information_schema  character_sets
information_schema  check_constraint_routine_usage
information_schema  check_constraints
information_schema  collation_character_set_applicability
information_schema  collations
information_schema  column_column_usage
information_schema  column_domain_usage
information_schema  column_options
information_schema  column_privileges
information_schema  column_statistics
information_schema  column_udt_usage
information_schema  columns
information_schema  columns_extensions
information_schema  constraint_column_usage
information_schema  constraint_table_usage
information_schema  data_type_privileges
information_schema  domain_constraints
information_schema  domain_udt_usage
information_schema  domains
information_schema  element_types
information_schema  enabled_roles
information_schema  engines
information_schema  events
information_schema  files
information_schema  foreign_data_wrapper_options
information_schema  foreign_data_wrappers
information_schema  foreign_server_options
information_schema  foreign_servers
information_schema  foreign_table_options
information_schema  foreign_tables
information_schema  information_schema_catalog_name
information_schema  key_column_usage
information_schema  keywords
information_schema  optimizer_trace
information_schema  parameters
information_schema  partitions
information_schema  plugins
information_schema  processlist
information_schema  profiling
information_schema  referential_constraints
information_schema  resource_groups
information_schema  role_column_grants
information_schema  role_routine_grants
information_schema  role_table_grants
information_schema  role_udt_grants
information_schema  role_usage_grants
information_schema  routine_privileges
information_schema  routines
information_schema  schema_privileges
information_schema  schemata
information_schema  schemata_extensions
information_schema  sequences
information_schema  session_variables
information_schema  sql_features
information_schema  sql_implementation_info
information_schema  sql_parts
information_schema  sql_sizing
information_schema  st_geometry_columns
information_schema  st_spatial_reference_systems
information_schema  st_units_of_measure
information_schema  statistics
information_schema  table_constraints
information_schema  table_constraints_extensions
information_schema  table_privileges
information_schema  tables
information_schema  tables_extensions
information_schema  tablespaces
information_schema  tablespaces_extensions
information_schema  transforms
information_schema  triggered_update_columns
information_schema  triggers
information_schema  type_privileges
information_schema  udt_privileges
information_schema  usage_privileges
information_schema  user_attributes
information_schema  user_defined_types
information_schema  user_mapping_options
information_schema  user_mappings
information_schema  user_privileges
information_schema  view_column_usage
information_schema  view_routine_usage
information_schema  view_table_usage
information_schema  views
pg_catalog          pg_aggregate
pg_catalog          pg_am
pg_catalog          pg_amop
pg_catalog          pg_amproc
pg_catalog          pg_attrdef
pg_catalog          pg_attribute
pg_catalog          pg_auth_members
pg_catalog          pg_authid
pg_catalog          pg_available_extension_versions
pg_catalog          pg_available_extensions
pg_catalog          pg_cast
pg_catalog          pg_class
pg_catalog          pg_collation
pg_catalog          pg_config
pg_catalog          pg_constraint
pg_catalog          pg_conversion
pg_catalog          pg_cursors
pg_catalog          pg_database
pg_catalog          pg_db_role_setting
pg_catalog          pg_default_acl
pg_catalog          pg_depend
pg_catalog          pg_description
pg_catalog          pg_enum
pg_catalog          pg_event_trigger
pg_catalog          pg_extension
pg_catalog          pg_file_settings
pg_catalog          pg_foreign_data_wrapper
pg_catalog          pg_foreign_server
pg_catalog          pg_foreign_table
pg_catalog          pg_group
pg_catalog          pg_hba_file_rules
pg_catalog          pg_index
pg_catalog          pg_indexes
pg_catalog          pg_inherits
pg_catalog          pg_init_privs
pg_catalog          pg_language
pg_catalog          pg_largeobject
pg_catalog          pg_largeobject_metadata
pg_catalog          pg_locks
pg_catalog          pg_matviews
pg_catalog          pg_namespace
pg_catalog          pg_opclass
pg_catalog          pg_operator
pg_catalog          pg_opfamily
pg_catalog          pg_partitioned_table
pg_catalog          pg_policies
pg_catalog          pg_policy
pg_catalog          pg_prepared_statements
pg_catalog          pg_prepared_xacts
pg_catalog          pg_proc
pg_catalog          pg_publication
pg_catalog          pg_publication_rel
pg_catalog          pg_publication_tables
pg_catalog          pg_range
pg_catalog          pg_replication_origin
pg_catalog          pg_replication_origin_status
pg_catalog          pg_replication_slots
pg_catalog          pg_rewrite
pg_catalog          pg_roles
pg_catalog          pg_rules
pg_catalog          pg_seclabel
pg_catalog          pg_seclabels
pg_catalog          pg_sequence
pg_catalog          pg_sequences
pg_catalog          pg_settings
pg_catalog          pg_shadow
pg_catalog          pg_shdepend
pg_catalog          pg_shdescription
pg_catalog          pg_shmem_allocations
pg_catalog          pg_shseclabel
pg_catalog          pg_stat_activity
pg_catalog          pg_stat_all_indexes
pg_catalog          pg_stat_all_tables
pg_catalog          pg_stat_archiver
pg_catalog          pg_stat_bgwriter
pg_catalog          pg_stat_database
pg_catalog          pg_stat_database_conflicts
pg_catalog          pg_stat_gssapi
pg_catalog          pg_stat_progress_analyze
pg_catalog          pg_stat_progress_basebackup
pg_catalog          pg_stat_progress_cluster
pg_catalog          pg_stat_progress_create_index
pg_catalog          pg_stat_progress_vacuum
pg_catalog          pg_stat_replication
pg_catalog          pg_stat_slru
pg_catalog          pg_stat_ssl
pg_catalog          pg_stat_subscription
pg_catalog          pg_stat_sys_indexes
pg_catalog          pg_stat_sys_tables
pg_catalog          pg_stat_user_functions
pg_catalog          pg_stat_user_indexes
pg_catalog          pg_stat_user_tables
pg_catalog          pg_stat_wal_receiver
pg_catalog          pg_stat_xact_all_tables
pg_catalog          pg_stat_xact_sys_tables
pg_catalog          pg_stat_xact_user_functions
pg_catalog          pg_stat_xact_user_tables
pg_catalog          pg_statio_all_indexes
pg_catalog          pg_statio_all_sequences
pg_catalog          pg_statio_all_tables
pg_catalog          pg_statio_sys_indexes
pg_catalog          pg_statio_sys_sequences
pg_catalog          pg_statio_sys_tables
pg_catalog          pg_statio_user_indexes
pg_catalog          pg_statio_user_sequences
pg_catalog          pg_statio_user_tables
pg_catalog          pg_statistic
pg_catalog          pg_statistic_ext
pg_catalog          pg_statistic_ext_data
pg_catalog          pg_stats
pg_catalog          pg_stats_ext
pg_catalog          pg_subscription
pg_catalog          pg_subscription_rel
pg_catalog          pg_tables
pg_catalog          pg_tablespace
pg_catalog          pg_timezone_abbrevs
pg_catalog          pg_timezone_names
pg_catalog          pg_transform
pg_catalog          pg_trigger
pg_catalog          pg_ts_config
pg_catalog          pg_ts_config_map
pg_catalog          pg_ts_dict
pg_catalog          pg_ts_parser
pg_catalog          pg_ts_template
pg_catalog          pg_type
pg_catalog          pg_user
pg_catalog          pg_user_mapping
pg_catalog          pg_user_mappings
pg_catalog          pg_views
pg_extension        geography_columns
pg_extension        geometry_columns
pg_extension        spatial_ref_sys

statement ok
CREATE DATABASE other_db

statement ok
CREATE TABLE other_db.xyz (i INT)

statement ok
CREATE SEQUENCE other_db.seq

statement ok
CREATE VIEW other_db.abc AS SELECT i from other_db.xyz

statement ok
GRANT UPDATE ON other_db.xyz TO testuser

user testuser

# Check the output with the current database set to 'test' (the
# defaults in tests). This will make the tables in other_db invisible to
# a non-root user.
query T
SELECT table_name FROM information_schema.tables WHERE table_catalog = 'other_db'
----

# Check that the other_db tables become visible when a prefix is specified
query T rowsort
SELECT table_name FROM other_db.information_schema.tables WHERE table_catalog = 'other_db' AND table_schema = 'public'
----
xyz
abc

# Check that one can see all tables with the empty prefix.
query T rowsort
SELECT table_name FROM "".information_schema.tables WHERE table_catalog = 'other_db'
AND (table_schema <> 'crdb_internal' OR table_name = 'node_build_info')
----
node_build_info
administrable_role_authorizations
applicable_roles
attributes
character_sets
check_constraint_routine_usage
check_constraints
collation_character_set_applicability
collations
column_column_usage
column_domain_usage
column_options
column_privileges
column_statistics
column_udt_usage
columns
columns_extensions
constraint_column_usage
constraint_table_usage
data_type_privileges
domain_constraints
domain_udt_usage
domains
element_types
enabled_roles
engines
events
files
foreign_data_wrapper_options
foreign_data_wrappers
foreign_server_options
foreign_servers
foreign_table_options
foreign_tables
information_schema_catalog_name
key_column_usage
keywords
optimizer_trace
parameters
partitions
plugins
processlist
profiling
referential_constraints
resource_groups
role_column_grants
role_routine_grants
role_table_grants
role_udt_grants
role_usage_grants
routine_privileges
routines
schema_privileges
schemata
schemata_extensions
sequences
session_variables
sql_features
sql_implementation_info
sql_parts
sql_sizing
st_geometry_columns
st_spatial_reference_systems
st_units_of_measure
statistics
table_constraints
table_constraints_extensions
table_privileges
tables
tables_extensions
tablespaces
tablespaces_extensions
transforms
triggered_update_columns
triggers
type_privileges
udt_privileges
usage_privileges
user_attributes
user_defined_types
user_mapping_options
user_mappings
user_privileges
view_column_usage
view_routine_usage
view_table_usage
views
pg_aggregate
pg_am
pg_amop
pg_amproc
pg_attrdef
pg_attribute
pg_auth_members
pg_authid
pg_available_extension_versions
pg_available_extensions
pg_cast
pg_class
pg_collation
pg_config
pg_constraint
pg_conversion
pg_cursors
pg_database
pg_db_role_setting
pg_default_acl
pg_depend
pg_description
pg_enum
pg_event_trigger
pg_extension
pg_file_settings
pg_foreign_data_wrapper
pg_foreign_server
pg_foreign_table
pg_group
pg_hba_file_rules
pg_index
pg_indexes
pg_inherits
pg_init_privs
pg_language
pg_largeobject
pg_largeobject_metadata
pg_locks
pg_matviews
pg_namespace
pg_opclass
pg_operator
pg_opfamily
pg_partitioned_table
pg_policies
pg_policy
pg_prepared_statements
pg_prepared_xacts
pg_proc
pg_publication
pg_publication_rel
pg_publication_tables
pg_range
pg_replication_origin
pg_replication_origin_status
pg_replication_slots
pg_rewrite
pg_roles
pg_rules
pg_seclabel
pg_seclabels
pg_sequence
pg_sequences
pg_settings
pg_shadow
pg_shdepend
pg_shdescription
pg_shmem_allocations
pg_shseclabel
pg_stat_activity
pg_stat_all_indexes
pg_stat_all_tables
pg_stat_archiver
pg_stat_bgwriter
pg_stat_database
pg_stat_database_conflicts
pg_stat_gssapi
pg_stat_progress_analyze
pg_stat_progress_basebackup
pg_stat_progress_cluster
pg_stat_progress_create_index
pg_stat_progress_vacuum
pg_stat_replication
pg_stat_slru
pg_stat_ssl
pg_stat_subscription
pg_stat_sys_indexes
pg_stat_sys_tables
pg_stat_user_functions
pg_stat_user_indexes
pg_stat_user_tables
pg_stat_wal_receiver
pg_stat_xact_all_tables
pg_stat_xact_sys_tables
pg_stat_xact_user_functions
pg_stat_xact_user_tables
pg_statio_all_indexes
pg_statio_all_sequences
pg_statio_all_tables
pg_statio_sys_indexes
pg_statio_sys_sequences
pg_statio_sys_tables
pg_statio_user_indexes
pg_statio_user_sequences
pg_statio_user_tables
pg_statistic
pg_statistic_ext
pg_statistic_ext_data
pg_stats
pg_stats_ext
pg_subscription
pg_subscription_rel
pg_tables
pg_tablespace
pg_timezone_abbrevs
pg_timezone_names
pg_transform
pg_trigger
pg_ts_config
pg_ts_config_map
pg_ts_dict
pg_ts_parser
pg_ts_template
pg_type
pg_user
pg_user_mapping
pg_user_mappings
pg_views
geography_columns
geometry_columns
spatial_ref_sys
xyz
abc

# Check that the other_db tables become visible to non-root when the current database is changed.
query T rowsort
SET DATABASE = other_db; SELECT table_name FROM information_schema.tables WHERE table_catalog = 'other_db' AND table_schema = 'public'
----
xyz
abc

user root

# Check that root sees everything when there is no current database
query T rowsort
SET DATABASE = ''; SELECT table_name FROM information_schema.tables WHERE table_catalog = 'other_db' AND table_schema = 'public'
----
xyz
abc

# Check that root doesn't see other things when there is a current database
query T
SET DATABASE = test; SELECT table_name FROM information_schema.tables WHERE table_schema = 'other_db'
----

# Check that tables from other schemas are found
query TT rowsort
CREATE SCHEMA myschema;
CREATE TABLE myschema.abc();
CREATE TABLE abc();
SELECT table_schema, table_name FROM information_schema.tables WHERE table_name = 'abc';
----
myschema  abc
public    abc

# Check that filtering works.
query T
SELECT table_name FROM other_db.information_schema.tables WHERE table_name > 't'  ORDER BY 1 DESC
----
zones
xyz
views
view_table_usage
view_routine_usage
view_column_usage
user_privileges
user_mappings
user_mapping_options
user_defined_types
user_attributes
usage_privileges
udt_privileges
type_privileges
triggers
triggered_update_columns
transforms
transaction_statistics_persisted_v22_2
transaction_statistics_persisted
transaction_statistics
transaction_contention_events
transaction_activity
tenant_usage_details
tablespaces_extensions
tablespaces
tables_extensions
tables
tables
table_spans
table_row_statistics
table_privileges
table_indexes
table_constraints_extensions
table_constraints
table_columns

# Check that the metadata is reported properly.
skipif config local-mixed-24.3
query TTTTT colnames
SELECT table_catalog, table_schema, table_name, table_type, is_insertable_into
FROM system.information_schema.tables
WHERE 
(table_schema <> 'crdb_internal' OR table_name = 'node_build_info') 
AND NOT (table_schema = 'public' AND table_name <> 'locations')
ORDER BY table_name, table_schema
----
table_catalog  table_schema        table_name                             table_type   is_insertable_into
system         information_schema  administrable_role_authorizations      SYSTEM VIEW  NO
system         information_schema  applicable_roles                       SYSTEM VIEW  NO
system         information_schema  attributes                             SYSTEM VIEW  NO
system         information_schema  character_sets                         SYSTEM VIEW  NO
system         information_schema  check_constraint_routine_usage         SYSTEM VIEW  NO
system         information_schema  check_constraints                      SYSTEM VIEW  NO
system         information_schema  collation_character_set_applicability  SYSTEM VIEW  NO
system         information_schema  collations                             SYSTEM VIEW  NO
system         information_schema  column_column_usage                    SYSTEM VIEW  NO
system         information_schema  column_domain_usage                    SYSTEM VIEW  NO
system         information_schema  column_options                         SYSTEM VIEW  NO
system         information_schema  column_privileges                      SYSTEM VIEW  NO
system         information_schema  column_statistics                      SYSTEM VIEW  NO
system         information_schema  column_udt_usage                       SYSTEM VIEW  NO
system         information_schema  columns                                SYSTEM VIEW  NO
system         information_schema  columns_extensions                     SYSTEM VIEW  NO
system         information_schema  constraint_column_usage                SYSTEM VIEW  NO
system         information_schema  constraint_table_usage                 SYSTEM VIEW  NO
system         information_schema  data_type_privileges                   SYSTEM VIEW  NO
system         information_schema  domain_constraints                     SYSTEM VIEW  NO
system         information_schema  domain_udt_usage                       SYSTEM VIEW  NO
system         information_schema  domains                                SYSTEM VIEW  NO
system         information_schema  element_types                          SYSTEM VIEW  NO
system         information_schema  enabled_roles                          SYSTEM VIEW  NO
system         information_schema  engines                                SYSTEM VIEW  NO
system         information_schema  events                                 SYSTEM VIEW  NO
system         information_schema  files                                  SYSTEM VIEW  NO
system         information_schema  foreign_data_wrapper_options           SYSTEM VIEW  NO
system         information_schema  foreign_data_wrappers                  SYSTEM VIEW  NO
system         information_schema  foreign_server_options                 SYSTEM VIEW  NO
system         information_schema  foreign_servers                        SYSTEM VIEW  NO
system         information_schema  foreign_table_options                  SYSTEM VIEW  NO
system         information_schema  foreign_tables                         SYSTEM VIEW  NO
system         pg_extension        geography_columns                      SYSTEM VIEW  NO
system         pg_extension        geometry_columns                       SYSTEM VIEW  NO
system         information_schema  information_schema_catalog_name        SYSTEM VIEW  NO
system         information_schema  key_column_usage                       SYSTEM VIEW  NO
system         information_schema  keywords                               SYSTEM VIEW  NO
system         public              locations                              BASE TABLE   YES
system         crdb_internal       node_build_info                        SYSTEM VIEW  NO
system         information_schema  optimizer_trace                        SYSTEM VIEW  NO
system         information_schema  parameters                             SYSTEM VIEW  NO
system         information_schema  partitions                             SYSTEM VIEW  NO
system         pg_catalog          pg_aggregate                           SYSTEM VIEW  NO
system         pg_catalog          pg_am                                  SYSTEM VIEW  NO
system         pg_catalog          pg_amop                                SYSTEM VIEW  NO
system         pg_catalog          pg_amproc                              SYSTEM VIEW  NO
system         pg_catalog          pg_attrdef                             SYSTEM VIEW  NO
system         pg_catalog          pg_attribute                           SYSTEM VIEW  NO
system         pg_catalog          pg_auth_members                        SYSTEM VIEW  NO
system         pg_catalog          pg_authid                              SYSTEM VIEW  NO
system         pg_catalog          pg_available_extension_versions        SYSTEM VIEW  NO
system         pg_catalog          pg_available_extensions                SYSTEM VIEW  NO
system         pg_catalog          pg_cast                                SYSTEM VIEW  NO
system         pg_catalog          pg_class                               SYSTEM VIEW  NO
system         pg_catalog          pg_collation                           SYSTEM VIEW  NO
system         pg_catalog          pg_config                              SYSTEM VIEW  NO
system         pg_catalog          pg_constraint                          SYSTEM VIEW  NO
system         pg_catalog          pg_conversion                          SYSTEM VIEW  NO
system         pg_catalog          pg_cursors                             SYSTEM VIEW  NO
system         pg_catalog          pg_database                            SYSTEM VIEW  NO
system         pg_catalog          pg_db_role_setting                     SYSTEM VIEW  NO
system         pg_catalog          pg_default_acl                         SYSTEM VIEW  NO
system         pg_catalog          pg_depend                              SYSTEM VIEW  NO
system         pg_catalog          pg_description                         SYSTEM VIEW  NO
system         pg_catalog          pg_enum                                SYSTEM VIEW  NO
system         pg_catalog          pg_event_trigger                       SYSTEM VIEW  NO
system         pg_catalog          pg_extension                           SYSTEM VIEW  NO
system         pg_catalog          pg_file_settings                       SYSTEM VIEW  NO
system         pg_catalog          pg_foreign_data_wrapper                SYSTEM VIEW  NO
system         pg_catalog          pg_foreign_server                      SYSTEM VIEW  NO
system         pg_catalog          pg_foreign_table                       SYSTEM VIEW  NO
system         pg_catalog          pg_group                               SYSTEM VIEW  NO
system         pg_catalog          pg_hba_file_rules                      SYSTEM VIEW  NO
system         pg_catalog          pg_index                               SYSTEM VIEW  NO
system         pg_catalog          pg_indexes                             SYSTEM VIEW  NO
system         pg_catalog          pg_inherits                            SYSTEM VIEW  NO
system         pg_catalog          pg_init_privs                          SYSTEM VIEW  NO
system         pg_catalog          pg_language                            SYSTEM VIEW  NO
system         pg_catalog          pg_largeobject                         SYSTEM VIEW  NO
system         pg_catalog          pg_largeobject_metadata                SYSTEM VIEW  NO
system         pg_catalog          pg_locks                               SYSTEM VIEW  NO
system         pg_catalog          pg_matviews                            SYSTEM VIEW  NO
system         pg_catalog          pg_namespace                           SYSTEM VIEW  NO
system         pg_catalog          pg_opclass                             SYSTEM VIEW  NO
system         pg_catalog          pg_operator                            SYSTEM VIEW  NO
system         pg_catalog          pg_opfamily                            SYSTEM VIEW  NO
system         pg_catalog          pg_partitioned_table                   SYSTEM VIEW  NO
system         pg_catalog          pg_policies                            SYSTEM VIEW  NO
system         pg_catalog          pg_policy                              SYSTEM VIEW  NO
system         pg_catalog          pg_prepared_statements                 SYSTEM VIEW  NO
system         pg_catalog          pg_prepared_xacts                      SYSTEM VIEW  NO
system         pg_catalog          pg_proc                                SYSTEM VIEW  NO
system         pg_catalog          pg_publication                         SYSTEM VIEW  NO
system         pg_catalog          pg_publication_rel                     SYSTEM VIEW  NO
system         pg_catalog          pg_publication_tables                  SYSTEM VIEW  NO
system         pg_catalog          pg_range                               SYSTEM VIEW  NO
system         pg_catalog          pg_replication_origin                  SYSTEM VIEW  NO
system         pg_catalog          pg_replication_origin_status           SYSTEM VIEW  NO
system         pg_catalog          pg_replication_slots                   SYSTEM VIEW  NO
system         pg_catalog          pg_rewrite                             SYSTEM VIEW  NO
system         pg_catalog          pg_roles                               SYSTEM VIEW  NO
system         pg_catalog          pg_rules                               SYSTEM VIEW  NO
system         pg_catalog          pg_seclabel                            SYSTEM VIEW  NO
system         pg_catalog          pg_seclabels                           SYSTEM VIEW  NO
system         pg_catalog          pg_sequence                            SYSTEM VIEW  NO
system         pg_catalog          pg_sequences                           SYSTEM VIEW  NO
system         pg_catalog          pg_settings                            SYSTEM VIEW  NO
system         pg_catalog          pg_shadow                              SYSTEM VIEW  NO
system         pg_catalog          pg_shdepend                            SYSTEM VIEW  NO
system         pg_catalog          pg_shdescription                       SYSTEM VIEW  NO
system         pg_catalog          pg_shmem_allocations                   SYSTEM VIEW  NO
system         pg_catalog          pg_shseclabel                          SYSTEM VIEW  NO
system         pg_catalog          pg_stat_activity                       SYSTEM VIEW  NO
system         pg_catalog          pg_stat_all_indexes                    SYSTEM VIEW  NO
system         pg_catalog          pg_stat_all_tables                     SYSTEM VIEW  NO
system         pg_catalog          pg_stat_archiver                       SYSTEM VIEW  NO
system         pg_catalog          pg_stat_bgwriter                       SYSTEM VIEW  NO
system         pg_catalog          pg_stat_database                       SYSTEM VIEW  NO
system         pg_catalog          pg_stat_database_conflicts             SYSTEM VIEW  NO
system         pg_catalog          pg_stat_gssapi                         SYSTEM VIEW  NO
system         pg_catalog          pg_stat_progress_analyze               SYSTEM VIEW  NO
system         pg_catalog          pg_stat_progress_basebackup            SYSTEM VIEW  NO
system         pg_catalog          pg_stat_progress_cluster               SYSTEM VIEW  NO
system         pg_catalog          pg_stat_progress_create_index          SYSTEM VIEW  NO
system         pg_catalog          pg_stat_progress_vacuum                SYSTEM VIEW  NO
system         pg_catalog          pg_stat_replication                    SYSTEM VIEW  NO
system         pg_catalog          pg_stat_slru                           SYSTEM VIEW  NO
system         pg_catalog          pg_stat_ssl                            SYSTEM VIEW  NO
system         pg_catalog          pg_stat_subscription                   SYSTEM VIEW  NO
system         pg_catalog          pg_stat_sys_indexes                    SYSTEM VIEW  NO
system         pg_catalog          pg_stat_sys_tables                     SYSTEM VIEW  NO
system         pg_catalog          pg_stat_user_functions                 SYSTEM VIEW  NO
system         pg_catalog          pg_stat_user_indexes                   SYSTEM VIEW  NO
system         pg_catalog          pg_stat_user_tables                    SYSTEM VIEW  NO
system         pg_catalog          pg_stat_wal_receiver                   SYSTEM VIEW  NO
system         pg_catalog          pg_stat_xact_all_tables                SYSTEM VIEW  NO
system         pg_catalog          pg_stat_xact_sys_tables                SYSTEM VIEW  NO
system         pg_catalog          pg_stat_xact_user_functions            SYSTEM VIEW  NO
system         pg_catalog          pg_stat_xact_user_tables               SYSTEM VIEW  NO
system         pg_catalog          pg_statio_all_indexes                  SYSTEM VIEW  NO
system         pg_catalog          pg_statio_all_sequences                SYSTEM VIEW  NO
system         pg_catalog          pg_statio_all_tables                   SYSTEM VIEW  NO
system         pg_catalog          pg_statio_sys_indexes                  SYSTEM VIEW  NO
system         pg_catalog          pg_statio_sys_sequences                SYSTEM VIEW  NO
system         pg_catalog          pg_statio_sys_tables                   SYSTEM VIEW  NO
system         pg_catalog          pg_statio_user_indexes                 SYSTEM VIEW  NO
system         pg_catalog          pg_statio_user_sequences               SYSTEM VIEW  NO
system         pg_catalog          pg_statio_user_tables                  SYSTEM VIEW  NO
system         pg_catalog          pg_statistic                           SYSTEM VIEW  NO
system         pg_catalog          pg_statistic_ext                       SYSTEM VIEW  NO
system         pg_catalog          pg_statistic_ext_data                  SYSTEM VIEW  NO
system         pg_catalog          pg_stats                               SYSTEM VIEW  NO
system         pg_catalog          pg_stats_ext                           SYSTEM VIEW  NO
system         pg_catalog          pg_subscription                        SYSTEM VIEW  NO
system         pg_catalog          pg_subscription_rel                    SYSTEM VIEW  NO
system         pg_catalog          pg_tables                              SYSTEM VIEW  NO
system         pg_catalog          pg_tablespace                          SYSTEM VIEW  NO
system         pg_catalog          pg_timezone_abbrevs                    SYSTEM VIEW  NO
system         pg_catalog          pg_timezone_names                      SYSTEM VIEW  NO
system         pg_catalog          pg_transform                           SYSTEM VIEW  NO
system         pg_catalog          pg_trigger                             SYSTEM VIEW  NO
system         pg_catalog          pg_ts_config                           SYSTEM VIEW  NO
system         pg_catalog          pg_ts_config_map                       SYSTEM VIEW  NO
system         pg_catalog          pg_ts_dict                             SYSTEM VIEW  NO
system         pg_catalog          pg_ts_parser                           SYSTEM VIEW  NO
system         pg_catalog          pg_ts_template                         SYSTEM VIEW  NO
system         pg_catalog          pg_type                                SYSTEM VIEW  NO
system         pg_catalog          pg_user                                SYSTEM VIEW  NO
system         pg_catalog          pg_user_mapping                        SYSTEM VIEW  NO
system         pg_catalog          pg_user_mappings                       SYSTEM VIEW  NO
system         pg_catalog          pg_views                               SYSTEM VIEW  NO
system         information_schema  plugins                                SYSTEM VIEW  NO
system         information_schema  processlist                            SYSTEM VIEW  NO
system         information_schema  profiling                              SYSTEM VIEW  NO
system         information_schema  referential_constraints                SYSTEM VIEW  NO
system         information_schema  resource_groups                        SYSTEM VIEW  NO
system         information_schema  role_column_grants                     SYSTEM VIEW  NO
system         information_schema  role_routine_grants                    SYSTEM VIEW  NO
system         information_schema  role_table_grants                      SYSTEM VIEW  NO
system         information_schema  role_udt_grants                        SYSTEM VIEW  NO
system         information_schema  role_usage_grants                      SYSTEM VIEW  NO
system         information_schema  routine_privileges                     SYSTEM VIEW  NO
system         information_schema  routines                               SYSTEM VIEW  NO
system         information_schema  schema_privileges                      SYSTEM VIEW  NO
system         information_schema  schemata                               SYSTEM VIEW  NO
system         information_schema  schemata_extensions                    SYSTEM VIEW  NO
system         information_schema  sequences                              SYSTEM VIEW  NO
system         information_schema  session_variables                      SYSTEM VIEW  NO
system         pg_extension        spatial_ref_sys                        SYSTEM VIEW  NO
system         information_schema  sql_features                           SYSTEM VIEW  NO
system         information_schema  sql_implementation_info                SYSTEM VIEW  NO
system         information_schema  sql_parts                              SYSTEM VIEW  NO
system         information_schema  sql_sizing                             SYSTEM VIEW  NO
system         information_schema  st_geometry_columns                    SYSTEM VIEW  NO
system         information_schema  st_spatial_reference_systems           SYSTEM VIEW  NO
system         information_schema  st_units_of_measure                    SYSTEM VIEW  NO
system         information_schema  statistics                             SYSTEM VIEW  NO
system         information_schema  table_constraints                      SYSTEM VIEW  NO
system         information_schema  table_constraints_extensions           SYSTEM VIEW  NO
system         information_schema  table_privileges                       SYSTEM VIEW  NO
system         information_schema  tables                                 SYSTEM VIEW  NO
system         information_schema  tables_extensions                      SYSTEM VIEW  NO
system         information_schema  tablespaces                            SYSTEM VIEW  NO
system         information_schema  tablespaces_extensions                 SYSTEM VIEW  NO
system         information_schema  transforms                             SYSTEM VIEW  NO
system         information_schema  triggered_update_columns               SYSTEM VIEW  NO
system         information_schema  triggers                               SYSTEM VIEW  NO
system         information_schema  type_privileges                        SYSTEM VIEW  NO
system         information_schema  udt_privileges                         SYSTEM VIEW  NO
system         information_schema  usage_privileges                       SYSTEM VIEW  NO
system         information_schema  user_attributes                        SYSTEM VIEW  NO
system         information_schema  user_defined_types                     SYSTEM VIEW  NO
system         information_schema  user_mapping_options                   SYSTEM VIEW  NO
system         information_schema  user_mappings                          SYSTEM VIEW  NO
system         information_schema  user_privileges                        SYSTEM VIEW  NO
system         information_schema  view_column_usage                      SYSTEM VIEW  NO
system         information_schema  view_routine_usage                     SYSTEM VIEW  NO
system         information_schema  view_table_usage                       SYSTEM VIEW  NO
system         information_schema  views                                  SYSTEM VIEW  NO

statement ok
ALTER TABLE other_db.xyz ADD COLUMN j INT

query TTI colnames
SELECT table_catalog, table_name, version
  FROM "".information_schema.tables
 WHERE table_catalog != 'system' AND version > 1 AND table_schema = 'public' ORDER BY 1,2
----
table_catalog  table_name  version
other_db       xyz         6

user testuser

# Check that another user cannot see other_db.adbc any more because they
# don't have privileges on it.
query TTTTTI colnames
SELECT * FROM other_db.information_schema.tables
WHERE table_catalog = 'other_db' AND table_schema = 'public'
ORDER BY table_name
----
table_catalog  table_schema  table_name  table_type  is_insertable_into  version
other_db       public        abc         VIEW        NO                  1
other_db       public        xyz         BASE TABLE  YES                 6


user root

statement ok
GRANT SELECT ON other_db.abc TO testuser

user testuser

# Check the user can see the tables now that they have privilege.
query TTTTTI colnames
SELECT * FROM other_db.information_schema.tables WHERE table_catalog = 'other_db' AND table_schema = 'public' ORDER BY 1, 3
----
table_catalog  table_schema  table_name  table_type  is_insertable_into  version
other_db       public        abc         VIEW        NO                  2
other_db       public        xyz         BASE TABLE  YES                 6

user root

statement ok
DROP DATABASE other_db CASCADE

statement ok
SET DATABASE = test

## information_schema.table_constraints
## information_schema.character_sets
## information_schema.check_constraints
## information_schema.constraint_column_usage

skipif config local-mixed-24.3
query TTTTTTTTT colnames
SELECT *
FROM system.information_schema.table_constraints
WHERE NOT (table_catalog = 'system' AND table_schema = 'public' AND table_name <> 'locations')
ORDER BY TABLE_NAME, CONSTRAINT_TYPE, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name   table_catalog  table_schema  table_name  constraint_type  is_deferrable  initially_deferred
system              public             29_21_1_not_null  system         public        locations   CHECK            NO             NO
system              public             29_21_2_not_null  system         public        locations   CHECK            NO             NO
system              public             29_21_3_not_null  system         public        locations   CHECK            NO             NO
system              public             29_21_4_not_null  system         public        locations   CHECK            NO             NO
system              public             primary           system         public        locations   PRIMARY KEY      NO             NO

query TTTTTTTT colnames,rowsort
SELECT *
FROM system.information_schema.character_sets
----
character_set_catalog  character_set_schema  character_set_name  character_repertoire  form_of_use  default_collate_catalog  default_collate_schema  default_collate_name
NULL                   NULL                  UTF8                UCS                   UTF8         defaultdb                NULL                    NULL
NULL                   NULL                  UTF8                UCS                   UTF8         postgres                 NULL                    NULL
NULL                   NULL                  UTF8                UCS                   UTF8         system                   NULL                    NULL
NULL                   NULL                  UTF8                UCS                   UTF8         test                     NULL                    NULL


skipif config local-mixed-24.3
query TTTT colnames
SELECT *
FROM system.information_schema.check_constraints
ORDER BY CONSTRAINT_CATALOG, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name                                                                                                 check_clause
system              public             29_11_1_not_null                                                                                                desc_id IS NOT NULL
system              public             29_11_2_not_null                                                                                                version IS NOT NULL
system              public             29_11_3_not_null                                                                                                sql_instance_id IS NOT NULL
system              public             29_11_4_not_null                                                                                                session_id IS NOT NULL
system              public             29_11_5_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_12_1_not_null                                                                                                timestamp IS NOT NULL
system              public             29_12_2_not_null                                                                                                eventType IS NOT NULL
system              public             29_12_3_not_null                                                                                                targetID IS NOT NULL
system              public             29_12_4_not_null                                                                                                reportingID IS NOT NULL
system              public             29_12_6_not_null                                                                                                uniqueID IS NOT NULL
system              public             29_13_1_not_null                                                                                                timestamp IS NOT NULL
system              public             29_13_2_not_null                                                                                                rangeID IS NOT NULL
system              public             29_13_3_not_null                                                                                                storeID IS NOT NULL
system              public             29_13_4_not_null                                                                                                eventType IS NOT NULL
system              public             29_13_7_not_null                                                                                                uniqueID IS NOT NULL
system              public             29_14_1_not_null                                                                                                key IS NOT NULL
system              public             29_14_3_not_null                                                                                                lastUpdated IS NOT NULL
system              public             29_15_1_not_null                                                                                                id IS NOT NULL
system              public             29_15_2_not_null                                                                                                status IS NOT NULL
system              public             29_15_3_not_null                                                                                                created IS NOT NULL
system              public             29_19_1_not_null                                                                                                id IS NOT NULL
system              public             29_19_2_not_null                                                                                                hashedSecret IS NOT NULL
system              public             29_19_3_not_null                                                                                                username IS NOT NULL
system              public             29_19_4_not_null                                                                                                createdAt IS NOT NULL
system              public             29_19_5_not_null                                                                                                expiresAt IS NOT NULL
system              public             29_19_7_not_null                                                                                                lastUsedAt IS NOT NULL
system              public             29_19_9_not_null                                                                                                user_id IS NOT NULL
system              public             29_20_10_not_null                                                                                               avgSize IS NOT NULL
system              public             29_20_1_not_null                                                                                                tableID IS NOT NULL
system              public             29_20_2_not_null                                                                                                statisticID IS NOT NULL
system              public             29_20_4_not_null                                                                                                columnIDs IS NOT NULL
system              public             29_20_5_not_null                                                                                                createdAt IS NOT NULL
system              public             29_20_6_not_null                                                                                                rowCount IS NOT NULL
system              public             29_20_7_not_null                                                                                                distinctCount IS NOT NULL
system              public             29_20_8_not_null                                                                                                nullCount IS NOT NULL
system              public             29_21_1_not_null                                                                                                localityKey IS NOT NULL
system              public             29_21_2_not_null                                                                                                localityValue IS NOT NULL
system              public             29_21_3_not_null                                                                                                latitude IS NOT NULL
system              public             29_21_4_not_null                                                                                                longitude IS NOT NULL
system              public             29_23_1_not_null                                                                                                role IS NOT NULL
system              public             29_23_2_not_null                                                                                                member IS NOT NULL
system              public             29_23_3_not_null                                                                                                isAdmin IS NOT NULL
system              public             29_23_4_not_null                                                                                                role_id IS NOT NULL
system              public             29_23_5_not_null                                                                                                member_id IS NOT NULL
system              public             29_24_1_not_null                                                                                                type IS NOT NULL
system              public             29_24_2_not_null                                                                                                object_id IS NOT NULL
system              public             29_24_3_not_null                                                                                                sub_id IS NOT NULL
system              public             29_24_4_not_null                                                                                                comment IS NOT NULL
system              public             29_25_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_25_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_25_3_not_null                                                                                                type IS NOT NULL
system              public             29_25_4_not_null                                                                                                config IS NOT NULL
system              public             29_25_5_not_null                                                                                                report_id IS NOT NULL
system              public             29_25_7_not_null                                                                                                violating_ranges IS NOT NULL
system              public             29_26_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_26_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_26_3_not_null                                                                                                locality IS NOT NULL
system              public             29_26_4_not_null                                                                                                report_id IS NOT NULL
system              public             29_26_5_not_null                                                                                                at_risk_ranges IS NOT NULL
system              public             29_27_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_27_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_27_3_not_null                                                                                                report_id IS NOT NULL
system              public             29_27_4_not_null                                                                                                total_ranges IS NOT NULL
system              public             29_27_5_not_null                                                                                                unavailable_ranges IS NOT NULL
system              public             29_27_6_not_null                                                                                                under_replicated_ranges IS NOT NULL
system              public             29_27_7_not_null                                                                                                over_replicated_ranges IS NOT NULL
system              public             29_28_1_not_null                                                                                                id IS NOT NULL
system              public             29_28_2_not_null                                                                                                generated IS NOT NULL
system              public             29_30_1_not_null                                                                                                parentID IS NOT NULL
system              public             29_30_2_not_null                                                                                                parentSchemaID IS NOT NULL
system              public             29_30_3_not_null                                                                                                name IS NOT NULL
system              public             29_31_1_not_null                                                                                                singleton IS NOT NULL
system              public             29_31_2_not_null                                                                                                version IS NOT NULL
system              public             29_31_3_not_null                                                                                                num_records IS NOT NULL
system              public             29_31_4_not_null                                                                                                num_spans IS NOT NULL
system              public             29_31_5_not_null                                                                                                total_bytes IS NOT NULL
system              public             29_32_1_not_null                                                                                                id IS NOT NULL
system              public             29_32_2_not_null                                                                                                ts IS NOT NULL
system              public             29_32_3_not_null                                                                                                meta_type IS NOT NULL
system              public             29_32_5_not_null                                                                                                num_spans IS NOT NULL
system              public             29_32_6_not_null                                                                                                spans IS NOT NULL
system              public             29_32_7_not_null                                                                                                verified IS NOT NULL
system              public             29_33_1_not_null                                                                                                username IS NOT NULL
system              public             29_33_2_not_null                                                                                                option IS NOT NULL
system              public             29_33_4_not_null                                                                                                user_id IS NOT NULL
system              public             29_34_1_not_null                                                                                                id IS NOT NULL
system              public             29_34_3_not_null                                                                                                data IS NOT NULL
system              public             29_35_11_not_null                                                                                               redacted IS NOT NULL
system              public             29_35_1_not_null                                                                                                id IS NOT NULL
system              public             29_35_2_not_null                                                                                                completed IS NOT NULL
system              public             29_35_3_not_null                                                                                                statement_fingerprint IS NOT NULL
system              public             29_35_5_not_null                                                                                                requested_at IS NOT NULL
system              public             29_36_1_not_null                                                                                                id IS NOT NULL
system              public             29_36_2_not_null                                                                                                statement_fingerprint IS NOT NULL
system              public             29_36_3_not_null                                                                                                statement IS NOT NULL
system              public             29_36_4_not_null                                                                                                collected_at IS NOT NULL
system              public             29_37_10_not_null                                                                                               execution_args IS NOT NULL
system              public             29_37_1_not_null                                                                                                schedule_id IS NOT NULL
system              public             29_37_2_not_null                                                                                                schedule_name IS NOT NULL
system              public             29_37_3_not_null                                                                                                created IS NOT NULL
system              public             29_37_4_not_null                                                                                                owner IS NOT NULL
system              public             29_37_9_not_null                                                                                                executor_type IS NOT NULL
system              public             29_39_1_not_null                                                                                                session_id IS NOT NULL
system              public             29_39_2_not_null                                                                                                expiration IS NOT NULL
system              public             29_39_3_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_3_1_not_null                                                                                                 id IS NOT NULL
system              public             29_40_1_not_null                                                                                                major IS NOT NULL
system              public             29_40_2_not_null                                                                                                minor IS NOT NULL
system              public             29_40_3_not_null                                                                                                patch IS NOT NULL
system              public             29_40_4_not_null                                                                                                internal IS NOT NULL
system              public             29_40_5_not_null                                                                                                completed_at IS NOT NULL
system              public             29_41_1_not_null                                                                                                id IS NOT NULL
system              public             29_41_2_not_null                                                                                                secret IS NOT NULL
system              public             29_41_3_not_null                                                                                                expiration IS NOT NULL
system              public             29_42_10_not_null                                                                                               plan IS NOT NULL
system              public             29_42_12_not_null                                                                                               index_recommendations IS NOT NULL
system              public             29_42_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_42_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_42_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_42_4_not_null                                                                                                plan_hash IS NOT NULL
system              public             29_42_5_not_null                                                                                                app_name IS NOT NULL
system              public             29_42_6_not_null                                                                                                node_id IS NOT NULL
system              public             29_42_7_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_42_8_not_null                                                                                                metadata IS NOT NULL
system              public             29_42_9_not_null                                                                                                statistics IS NOT NULL
system              public             29_43_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_43_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_43_3_not_null                                                                                                app_name IS NOT NULL
system              public             29_43_4_not_null                                                                                                node_id IS NOT NULL
system              public             29_43_5_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_43_6_not_null                                                                                                metadata IS NOT NULL
system              public             29_43_7_not_null                                                                                                statistics IS NOT NULL
system              public             29_44_1_not_null                                                                                                database_id IS NOT NULL
system              public             29_44_2_not_null                                                                                                role_name IS NOT NULL
system              public             29_44_3_not_null                                                                                                settings IS NOT NULL
system              public             29_44_4_not_null                                                                                                role_id IS NOT NULL
system              public             29_45_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_45_2_not_null                                                                                                instance_id IS NOT NULL
system              public             29_45_3_not_null                                                                                                next_instance_id IS NOT NULL
system              public             29_45_4_not_null                                                                                                last_update IS NOT NULL
system              public             29_46_1_not_null                                                                                                id IS NOT NULL
system              public             29_46_6_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_47_1_not_null                                                                                                start_key IS NOT NULL
system              public             29_47_2_not_null                                                                                                end_key IS NOT NULL
system              public             29_47_3_not_null                                                                                                config IS NOT NULL
system              public             29_48_1_not_null                                                                                                value IS NOT NULL
system              public             29_4_1_not_null                                                                                                 username IS NOT NULL
system              public             29_4_3_not_null                                                                                                 isRole IS NOT NULL
system              public             29_4_4_not_null                                                                                                 user_id IS NOT NULL
system              public             29_50_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_50_2_not_null                                                                                                name IS NOT NULL
system              public             29_50_3_not_null                                                                                                value IS NOT NULL
system              public             29_50_4_not_null                                                                                                last_updated IS NOT NULL
system              public             29_50_5_not_null                                                                                                value_type IS NOT NULL
system              public             29_51_1_not_null                                                                                                singleton IS NOT NULL
system              public             29_51_2_not_null                                                                                                span_count IS NOT NULL
system              public             29_52_1_not_null                                                                                                username IS NOT NULL
system              public             29_52_2_not_null                                                                                                path IS NOT NULL
system              public             29_52_3_not_null                                                                                                privileges IS NOT NULL
system              public             29_52_4_not_null                                                                                                grant_options IS NOT NULL
system              public             29_52_5_not_null                                                                                                user_id IS NOT NULL
system              public             29_53_1_not_null                                                                                                connection_name IS NOT NULL
system              public             29_53_2_not_null                                                                                                created IS NOT NULL
system              public             29_53_3_not_null                                                                                                updated IS NOT NULL
system              public             29_53_4_not_null                                                                                                connection_type IS NOT NULL
system              public             29_53_5_not_null                                                                                                connection_details IS NOT NULL
system              public             29_53_6_not_null                                                                                                owner IS NOT NULL
system              public             29_53_7_not_null                                                                                                owner_id IS NOT NULL
system              public             29_54_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_54_2_not_null                                                                                                info_key IS NOT NULL
system              public             29_54_3_not_null                                                                                                written IS NOT NULL
system              public             29_55_1_not_null                                                                                                id IS NOT NULL
system              public             29_56_1_not_null                                                                                                id IS NOT NULL
system              public             29_56_2_not_null                                                                                                sample_id IS NOT NULL
system              public             29_56_3_not_null                                                                                                start_key_id IS NOT NULL
system              public             29_56_4_not_null                                                                                                end_key_id IS NOT NULL
system              public             29_56_5_not_null                                                                                                requests IS NOT NULL
system              public             29_57_1_not_null                                                                                                id IS NOT NULL
system              public             29_57_2_not_null                                                                                                sample_time IS NOT NULL
system              public             29_58_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_58_2_not_null                                                                                                boundaries IS NOT NULL
system              public             29_59_1_not_null                                                                                                id IS NOT NULL
system              public             29_59_2_not_null                                                                                                created IS NOT NULL
system              public             29_59_3_not_null                                                                                                owner IS NOT NULL
system              public             29_59_4_not_null                                                                                                owner_id IS NOT NULL
system              public             29_59_5_not_null                                                                                                min_version IS NOT NULL
system              public             29_59_7_not_null                                                                                                type IS NOT NULL
system              public             29_59_8_not_null                                                                                                value IS NOT NULL
system              public             29_5_1_not_null                                                                                                 id IS NOT NULL
system              public             29_60_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_60_2_not_null                                                                                                issuer IS NOT NULL
system              public             29_60_3_not_null                                                                                                task_id IS NOT NULL
system              public             29_60_4_not_null                                                                                                created IS NOT NULL
system              public             29_60_5_not_null                                                                                                payload_id IS NOT NULL
system              public             29_60_6_not_null                                                                                                owner IS NOT NULL
system              public             29_60_7_not_null                                                                                                owner_id IS NOT NULL
system              public             29_61_10_not_null                                                                                               index_recommendations IS NOT NULL
system              public             29_61_11_not_null                                                                                               execution_count IS NOT NULL
system              public             29_61_12_not_null                                                                                               execution_total_seconds IS NOT NULL
system              public             29_61_13_not_null                                                                                               execution_total_cluster_seconds IS NOT NULL
system              public             29_61_14_not_null                                                                                               contention_time_avg_seconds IS NOT NULL
system              public             29_61_15_not_null                                                                                               cpu_sql_avg_nanos IS NOT NULL
system              public             29_61_16_not_null                                                                                               service_latency_avg_seconds IS NOT NULL
system              public             29_61_17_not_null                                                                                               service_latency_p99_seconds IS NOT NULL
system              public             29_61_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_61_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_61_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_61_4_not_null                                                                                                plan_hash IS NOT NULL
system              public             29_61_5_not_null                                                                                                app_name IS NOT NULL
system              public             29_61_6_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_61_7_not_null                                                                                                metadata IS NOT NULL
system              public             29_61_8_not_null                                                                                                statistics IS NOT NULL
system              public             29_61_9_not_null                                                                                                plan IS NOT NULL
system              public             29_62_10_not_null                                                                                               execution_total_cluster_seconds IS NOT NULL
system              public             29_62_11_not_null                                                                                               contention_time_avg_seconds IS NOT NULL
system              public             29_62_12_not_null                                                                                               cpu_sql_avg_nanos IS NOT NULL
system              public             29_62_13_not_null                                                                                               service_latency_avg_seconds IS NOT NULL
system              public             29_62_14_not_null                                                                                               service_latency_p99_seconds IS NOT NULL
system              public             29_62_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_62_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_62_3_not_null                                                                                                app_name IS NOT NULL
system              public             29_62_4_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_62_5_not_null                                                                                                metadata IS NOT NULL
system              public             29_62_6_not_null                                                                                                statistics IS NOT NULL
system              public             29_62_7_not_null                                                                                                query IS NOT NULL
system              public             29_62_8_not_null                                                                                                execution_count IS NOT NULL
system              public             29_62_9_not_null                                                                                                execution_total_seconds IS NOT NULL
system              public             29_63_1_not_null                                                                                                value IS NOT NULL
system              public             29_64_1_not_null                                                                                                created_at IS NOT NULL
system              public             29_64_2_not_null                                                                                                database_id IS NOT NULL
system              public             29_64_3_not_null                                                                                                table_id IS NOT NULL
system              public             29_64_4_not_null                                                                                                index_id IS NOT NULL
system              public             29_64_5_not_null                                                                                                statistics IS NOT NULL
system              public             29_65_1_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_65_22_not_null                                                                                               created IS NOT NULL
system              public             29_65_2_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_65_5_not_null                                                                                                session_id IS NOT NULL
system              public             29_66_1_not_null                                                                                                session_id IS NOT NULL
system              public             29_66_28_not_null                                                                                               created IS NOT NULL
system              public             29_66_2_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_66_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_66_4_not_null                                                                                                statement_id IS NOT NULL
system              public             29_66_5_not_null                                                                                                statement_fingerprint_id IS NOT NULL
system              public             29_67_10_not_null                                                                                               total_ranges IS NOT NULL
system              public             29_67_11_not_null                                                                                               total_live_data_bytes IS NOT NULL
system              public             29_67_12_not_null                                                                                               total_data_bytes IS NOT NULL
system              public             29_67_13_not_null                                                                                               perc_live_data IS NOT NULL
system              public             29_67_15_not_null                                                                                               last_updated IS NOT NULL
system              public             29_67_16_not_null                                                                                               table_type IS NOT NULL
system              public             29_67_17_not_null                                                                                               details IS NOT NULL
system              public             29_67_1_not_null                                                                                                db_id IS NOT NULL
system              public             29_67_2_not_null                                                                                                table_id IS NOT NULL
system              public             29_67_3_not_null                                                                                                db_name IS NOT NULL
system              public             29_67_4_not_null                                                                                                schema_name IS NOT NULL
system              public             29_67_5_not_null                                                                                                table_name IS NOT NULL
system              public             29_67_6_not_null                                                                                                total_columns IS NOT NULL
system              public             29_67_7_not_null                                                                                                total_indexes IS NOT NULL
system              public             29_67_8_not_null                                                                                                store_ids IS NOT NULL
system              public             29_67_9_not_null                                                                                                replication_size_bytes IS NOT NULL
system              public             29_68_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_68_2_not_null                                                                                                written IS NOT NULL
system              public             29_69_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_69_2_not_null                                                                                                written IS NOT NULL
system              public             29_6_1_not_null                                                                                                 name IS NOT NULL
system              public             29_6_2_not_null                                                                                                 value IS NOT NULL
system              public             29_6_3_not_null                                                                                                 lastUpdated IS NOT NULL
system              public             29_70_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_70_2_not_null                                                                                                written IS NOT NULL
system              public             29_70_3_not_null                                                                                                status IS NOT NULL
system              public             29_71_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_71_2_not_null                                                                                                written IS NOT NULL
system              public             29_71_3_not_null                                                                                                kind IS NOT NULL
system              public             29_71_4_not_null                                                                                                message IS NOT NULL
system              public             29_72_1_not_null                                                                                                global_id IS NOT NULL
system              public             29_72_2_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_72_4_not_null                                                                                                prepared IS NOT NULL
system              public             29_72_5_not_null                                                                                                owner IS NOT NULL
system              public             29_72_6_not_null                                                                                                database IS NOT NULL
system              public             29_7_1_not_null                                                                                                 value IS NOT NULL
system              public             29_8_1_not_null                                                                                                 id IS NOT NULL
system              public             29_9_1_not_null                                                                                                 crdb_region IS NOT NULL
system              public             check_bounds                                                                                                    ((start_key < end_key))
system              public             check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8  ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)))
system              public             check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8                                       ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)))
system              public             check_crdb_internal_created_at_database_id_index_id_table_id_shard_16                                           ((crdb_internal_created_at_database_id_index_id_table_id_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_end_time_start_time_shard_16                                                                ((crdb_internal_end_time_start_time_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_end_time_start_time_shard_16                                                                ((crdb_internal_end_time_start_time_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_last_updated_table_id_shard_16                                                              ((crdb_internal_last_updated_table_id_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_sampling_probability                                                                                      ((sampling_probability BETWEEN 0.0:::FLOAT8 AND 1.0:::FLOAT8))
system              public             check_singleton                                                                                                 ((singleton))
system              public             single_row                                                                                                      ((singleton))

skipif config local-mixed-24.3
query TTTTTTT colnames
SELECT *
FROM system.information_schema.constraint_column_usage
WHERE NOT (table_catalog = 'system' AND table_schema = 'public' AND table_name <> 'locations')
ORDER BY TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME
----
table_catalog  table_schema  table_name  column_name    constraint_catalog  constraint_schema  constraint_name
system         public        locations   localityKey    system              public             primary
system         public        locations   localityValue  system              public             primary

skipif config local-mixed-24.3
query TTTTTTT colnames
SELECT *
FROM system.information_schema.constraint_column_usage
WHERE NOT (table_catalog = 'system' AND table_schema = 'public' AND table_name <> 'locations')
ORDER BY TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME
----
table_catalog  table_schema  table_name  column_name    constraint_catalog  constraint_schema  constraint_name
system         public        locations   localityKey    system              public             primary
system         public        locations   localityValue  system              public             primary

skipif config local-mixed-24.3
query TTTT colnames
SELECT *
FROM system.information_schema.check_constraints
ORDER BY CONSTRAINT_CATALOG, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name                                                                                                 check_clause
system              public             29_11_1_not_null                                                                                                desc_id IS NOT NULL
system              public             29_11_2_not_null                                                                                                version IS NOT NULL
system              public             29_11_3_not_null                                                                                                sql_instance_id IS NOT NULL
system              public             29_11_4_not_null                                                                                                session_id IS NOT NULL
system              public             29_11_5_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_12_1_not_null                                                                                                timestamp IS NOT NULL
system              public             29_12_2_not_null                                                                                                eventType IS NOT NULL
system              public             29_12_3_not_null                                                                                                targetID IS NOT NULL
system              public             29_12_4_not_null                                                                                                reportingID IS NOT NULL
system              public             29_12_6_not_null                                                                                                uniqueID IS NOT NULL
system              public             29_13_1_not_null                                                                                                timestamp IS NOT NULL
system              public             29_13_2_not_null                                                                                                rangeID IS NOT NULL
system              public             29_13_3_not_null                                                                                                storeID IS NOT NULL
system              public             29_13_4_not_null                                                                                                eventType IS NOT NULL
system              public             29_13_7_not_null                                                                                                uniqueID IS NOT NULL
system              public             29_14_1_not_null                                                                                                key IS NOT NULL
system              public             29_14_3_not_null                                                                                                lastUpdated IS NOT NULL
system              public             29_15_1_not_null                                                                                                id IS NOT NULL
system              public             29_15_2_not_null                                                                                                status IS NOT NULL
system              public             29_15_3_not_null                                                                                                created IS NOT NULL
system              public             29_19_1_not_null                                                                                                id IS NOT NULL
system              public             29_19_2_not_null                                                                                                hashedSecret IS NOT NULL
system              public             29_19_3_not_null                                                                                                username IS NOT NULL
system              public             29_19_4_not_null                                                                                                createdAt IS NOT NULL
system              public             29_19_5_not_null                                                                                                expiresAt IS NOT NULL
system              public             29_19_7_not_null                                                                                                lastUsedAt IS NOT NULL
system              public             29_19_9_not_null                                                                                                user_id IS NOT NULL
system              public             29_20_10_not_null                                                                                               avgSize IS NOT NULL
system              public             29_20_1_not_null                                                                                                tableID IS NOT NULL
system              public             29_20_2_not_null                                                                                                statisticID IS NOT NULL
system              public             29_20_4_not_null                                                                                                columnIDs IS NOT NULL
system              public             29_20_5_not_null                                                                                                createdAt IS NOT NULL
system              public             29_20_6_not_null                                                                                                rowCount IS NOT NULL
system              public             29_20_7_not_null                                                                                                distinctCount IS NOT NULL
system              public             29_20_8_not_null                                                                                                nullCount IS NOT NULL
system              public             29_21_1_not_null                                                                                                localityKey IS NOT NULL
system              public             29_21_2_not_null                                                                                                localityValue IS NOT NULL
system              public             29_21_3_not_null                                                                                                latitude IS NOT NULL
system              public             29_21_4_not_null                                                                                                longitude IS NOT NULL
system              public             29_23_1_not_null                                                                                                role IS NOT NULL
system              public             29_23_2_not_null                                                                                                member IS NOT NULL
system              public             29_23_3_not_null                                                                                                isAdmin IS NOT NULL
system              public             29_23_4_not_null                                                                                                role_id IS NOT NULL
system              public             29_23_5_not_null                                                                                                member_id IS NOT NULL
system              public             29_24_1_not_null                                                                                                type IS NOT NULL
system              public             29_24_2_not_null                                                                                                object_id IS NOT NULL
system              public             29_24_3_not_null                                                                                                sub_id IS NOT NULL
system              public             29_24_4_not_null                                                                                                comment IS NOT NULL
system              public             29_25_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_25_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_25_3_not_null                                                                                                type IS NOT NULL
system              public             29_25_4_not_null                                                                                                config IS NOT NULL
system              public             29_25_5_not_null                                                                                                report_id IS NOT NULL
system              public             29_25_7_not_null                                                                                                violating_ranges IS NOT NULL
system              public             29_26_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_26_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_26_3_not_null                                                                                                locality IS NOT NULL
system              public             29_26_4_not_null                                                                                                report_id IS NOT NULL
system              public             29_26_5_not_null                                                                                                at_risk_ranges IS NOT NULL
system              public             29_27_1_not_null                                                                                                zone_id IS NOT NULL
system              public             29_27_2_not_null                                                                                                subzone_id IS NOT NULL
system              public             29_27_3_not_null                                                                                                report_id IS NOT NULL
system              public             29_27_4_not_null                                                                                                total_ranges IS NOT NULL
system              public             29_27_5_not_null                                                                                                unavailable_ranges IS NOT NULL
system              public             29_27_6_not_null                                                                                                under_replicated_ranges IS NOT NULL
system              public             29_27_7_not_null                                                                                                over_replicated_ranges IS NOT NULL
system              public             29_28_1_not_null                                                                                                id IS NOT NULL
system              public             29_28_2_not_null                                                                                                generated IS NOT NULL
system              public             29_30_1_not_null                                                                                                parentID IS NOT NULL
system              public             29_30_2_not_null                                                                                                parentSchemaID IS NOT NULL
system              public             29_30_3_not_null                                                                                                name IS NOT NULL
system              public             29_31_1_not_null                                                                                                singleton IS NOT NULL
system              public             29_31_2_not_null                                                                                                version IS NOT NULL
system              public             29_31_3_not_null                                                                                                num_records IS NOT NULL
system              public             29_31_4_not_null                                                                                                num_spans IS NOT NULL
system              public             29_31_5_not_null                                                                                                total_bytes IS NOT NULL
system              public             29_32_1_not_null                                                                                                id IS NOT NULL
system              public             29_32_2_not_null                                                                                                ts IS NOT NULL
system              public             29_32_3_not_null                                                                                                meta_type IS NOT NULL
system              public             29_32_5_not_null                                                                                                num_spans IS NOT NULL
system              public             29_32_6_not_null                                                                                                spans IS NOT NULL
system              public             29_32_7_not_null                                                                                                verified IS NOT NULL
system              public             29_33_1_not_null                                                                                                username IS NOT NULL
system              public             29_33_2_not_null                                                                                                option IS NOT NULL
system              public             29_33_4_not_null                                                                                                user_id IS NOT NULL
system              public             29_34_1_not_null                                                                                                id IS NOT NULL
system              public             29_34_3_not_null                                                                                                data IS NOT NULL
system              public             29_35_11_not_null                                                                                               redacted IS NOT NULL
system              public             29_35_1_not_null                                                                                                id IS NOT NULL
system              public             29_35_2_not_null                                                                                                completed IS NOT NULL
system              public             29_35_3_not_null                                                                                                statement_fingerprint IS NOT NULL
system              public             29_35_5_not_null                                                                                                requested_at IS NOT NULL
system              public             29_36_1_not_null                                                                                                id IS NOT NULL
system              public             29_36_2_not_null                                                                                                statement_fingerprint IS NOT NULL
system              public             29_36_3_not_null                                                                                                statement IS NOT NULL
system              public             29_36_4_not_null                                                                                                collected_at IS NOT NULL
system              public             29_37_10_not_null                                                                                               execution_args IS NOT NULL
system              public             29_37_1_not_null                                                                                                schedule_id IS NOT NULL
system              public             29_37_2_not_null                                                                                                schedule_name IS NOT NULL
system              public             29_37_3_not_null                                                                                                created IS NOT NULL
system              public             29_37_4_not_null                                                                                                owner IS NOT NULL
system              public             29_37_9_not_null                                                                                                executor_type IS NOT NULL
system              public             29_39_1_not_null                                                                                                session_id IS NOT NULL
system              public             29_39_2_not_null                                                                                                expiration IS NOT NULL
system              public             29_39_3_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_3_1_not_null                                                                                                 id IS NOT NULL
system              public             29_40_1_not_null                                                                                                major IS NOT NULL
system              public             29_40_2_not_null                                                                                                minor IS NOT NULL
system              public             29_40_3_not_null                                                                                                patch IS NOT NULL
system              public             29_40_4_not_null                                                                                                internal IS NOT NULL
system              public             29_40_5_not_null                                                                                                completed_at IS NOT NULL
system              public             29_41_1_not_null                                                                                                id IS NOT NULL
system              public             29_41_2_not_null                                                                                                secret IS NOT NULL
system              public             29_41_3_not_null                                                                                                expiration IS NOT NULL
system              public             29_42_10_not_null                                                                                               plan IS NOT NULL
system              public             29_42_12_not_null                                                                                               index_recommendations IS NOT NULL
system              public             29_42_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_42_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_42_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_42_4_not_null                                                                                                plan_hash IS NOT NULL
system              public             29_42_5_not_null                                                                                                app_name IS NOT NULL
system              public             29_42_6_not_null                                                                                                node_id IS NOT NULL
system              public             29_42_7_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_42_8_not_null                                                                                                metadata IS NOT NULL
system              public             29_42_9_not_null                                                                                                statistics IS NOT NULL
system              public             29_43_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_43_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_43_3_not_null                                                                                                app_name IS NOT NULL
system              public             29_43_4_not_null                                                                                                node_id IS NOT NULL
system              public             29_43_5_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_43_6_not_null                                                                                                metadata IS NOT NULL
system              public             29_43_7_not_null                                                                                                statistics IS NOT NULL
system              public             29_44_1_not_null                                                                                                database_id IS NOT NULL
system              public             29_44_2_not_null                                                                                                role_name IS NOT NULL
system              public             29_44_3_not_null                                                                                                settings IS NOT NULL
system              public             29_44_4_not_null                                                                                                role_id IS NOT NULL
system              public             29_45_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_45_2_not_null                                                                                                instance_id IS NOT NULL
system              public             29_45_3_not_null                                                                                                next_instance_id IS NOT NULL
system              public             29_45_4_not_null                                                                                                last_update IS NOT NULL
system              public             29_46_1_not_null                                                                                                id IS NOT NULL
system              public             29_46_6_not_null                                                                                                crdb_region IS NOT NULL
system              public             29_47_1_not_null                                                                                                start_key IS NOT NULL
system              public             29_47_2_not_null                                                                                                end_key IS NOT NULL
system              public             29_47_3_not_null                                                                                                config IS NOT NULL
system              public             29_48_1_not_null                                                                                                value IS NOT NULL
system              public             29_4_1_not_null                                                                                                 username IS NOT NULL
system              public             29_4_3_not_null                                                                                                 isRole IS NOT NULL
system              public             29_4_4_not_null                                                                                                 user_id IS NOT NULL
system              public             29_50_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_50_2_not_null                                                                                                name IS NOT NULL
system              public             29_50_3_not_null                                                                                                value IS NOT NULL
system              public             29_50_4_not_null                                                                                                last_updated IS NOT NULL
system              public             29_50_5_not_null                                                                                                value_type IS NOT NULL
system              public             29_51_1_not_null                                                                                                singleton IS NOT NULL
system              public             29_51_2_not_null                                                                                                span_count IS NOT NULL
system              public             29_52_1_not_null                                                                                                username IS NOT NULL
system              public             29_52_2_not_null                                                                                                path IS NOT NULL
system              public             29_52_3_not_null                                                                                                privileges IS NOT NULL
system              public             29_52_4_not_null                                                                                                grant_options IS NOT NULL
system              public             29_52_5_not_null                                                                                                user_id IS NOT NULL
system              public             29_53_1_not_null                                                                                                connection_name IS NOT NULL
system              public             29_53_2_not_null                                                                                                created IS NOT NULL
system              public             29_53_3_not_null                                                                                                updated IS NOT NULL
system              public             29_53_4_not_null                                                                                                connection_type IS NOT NULL
system              public             29_53_5_not_null                                                                                                connection_details IS NOT NULL
system              public             29_53_6_not_null                                                                                                owner IS NOT NULL
system              public             29_53_7_not_null                                                                                                owner_id IS NOT NULL
system              public             29_54_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_54_2_not_null                                                                                                info_key IS NOT NULL
system              public             29_54_3_not_null                                                                                                written IS NOT NULL
system              public             29_55_1_not_null                                                                                                id IS NOT NULL
system              public             29_56_1_not_null                                                                                                id IS NOT NULL
system              public             29_56_2_not_null                                                                                                sample_id IS NOT NULL
system              public             29_56_3_not_null                                                                                                start_key_id IS NOT NULL
system              public             29_56_4_not_null                                                                                                end_key_id IS NOT NULL
system              public             29_56_5_not_null                                                                                                requests IS NOT NULL
system              public             29_57_1_not_null                                                                                                id IS NOT NULL
system              public             29_57_2_not_null                                                                                                sample_time IS NOT NULL
system              public             29_58_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_58_2_not_null                                                                                                boundaries IS NOT NULL
system              public             29_59_1_not_null                                                                                                id IS NOT NULL
system              public             29_59_2_not_null                                                                                                created IS NOT NULL
system              public             29_59_3_not_null                                                                                                owner IS NOT NULL
system              public             29_59_4_not_null                                                                                                owner_id IS NOT NULL
system              public             29_59_5_not_null                                                                                                min_version IS NOT NULL
system              public             29_59_7_not_null                                                                                                type IS NOT NULL
system              public             29_59_8_not_null                                                                                                value IS NOT NULL
system              public             29_5_1_not_null                                                                                                 id IS NOT NULL
system              public             29_60_1_not_null                                                                                                tenant_id IS NOT NULL
system              public             29_60_2_not_null                                                                                                issuer IS NOT NULL
system              public             29_60_3_not_null                                                                                                task_id IS NOT NULL
system              public             29_60_4_not_null                                                                                                created IS NOT NULL
system              public             29_60_5_not_null                                                                                                payload_id IS NOT NULL
system              public             29_60_6_not_null                                                                                                owner IS NOT NULL
system              public             29_60_7_not_null                                                                                                owner_id IS NOT NULL
system              public             29_61_10_not_null                                                                                               index_recommendations IS NOT NULL
system              public             29_61_11_not_null                                                                                               execution_count IS NOT NULL
system              public             29_61_12_not_null                                                                                               execution_total_seconds IS NOT NULL
system              public             29_61_13_not_null                                                                                               execution_total_cluster_seconds IS NOT NULL
system              public             29_61_14_not_null                                                                                               contention_time_avg_seconds IS NOT NULL
system              public             29_61_15_not_null                                                                                               cpu_sql_avg_nanos IS NOT NULL
system              public             29_61_16_not_null                                                                                               service_latency_avg_seconds IS NOT NULL
system              public             29_61_17_not_null                                                                                               service_latency_p99_seconds IS NOT NULL
system              public             29_61_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_61_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_61_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_61_4_not_null                                                                                                plan_hash IS NOT NULL
system              public             29_61_5_not_null                                                                                                app_name IS NOT NULL
system              public             29_61_6_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_61_7_not_null                                                                                                metadata IS NOT NULL
system              public             29_61_8_not_null                                                                                                statistics IS NOT NULL
system              public             29_61_9_not_null                                                                                                plan IS NOT NULL
system              public             29_62_10_not_null                                                                                               execution_total_cluster_seconds IS NOT NULL
system              public             29_62_11_not_null                                                                                               contention_time_avg_seconds IS NOT NULL
system              public             29_62_12_not_null                                                                                               cpu_sql_avg_nanos IS NOT NULL
system              public             29_62_13_not_null                                                                                               service_latency_avg_seconds IS NOT NULL
system              public             29_62_14_not_null                                                                                               service_latency_p99_seconds IS NOT NULL
system              public             29_62_1_not_null                                                                                                aggregated_ts IS NOT NULL
system              public             29_62_2_not_null                                                                                                fingerprint_id IS NOT NULL
system              public             29_62_3_not_null                                                                                                app_name IS NOT NULL
system              public             29_62_4_not_null                                                                                                agg_interval IS NOT NULL
system              public             29_62_5_not_null                                                                                                metadata IS NOT NULL
system              public             29_62_6_not_null                                                                                                statistics IS NOT NULL
system              public             29_62_7_not_null                                                                                                query IS NOT NULL
system              public             29_62_8_not_null                                                                                                execution_count IS NOT NULL
system              public             29_62_9_not_null                                                                                                execution_total_seconds IS NOT NULL
system              public             29_63_1_not_null                                                                                                value IS NOT NULL
system              public             29_64_1_not_null                                                                                                created_at IS NOT NULL
system              public             29_64_2_not_null                                                                                                database_id IS NOT NULL
system              public             29_64_3_not_null                                                                                                table_id IS NOT NULL
system              public             29_64_4_not_null                                                                                                index_id IS NOT NULL
system              public             29_64_5_not_null                                                                                                statistics IS NOT NULL
system              public             29_65_1_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_65_22_not_null                                                                                               created IS NOT NULL
system              public             29_65_2_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_65_5_not_null                                                                                                session_id IS NOT NULL
system              public             29_66_1_not_null                                                                                                session_id IS NOT NULL
system              public             29_66_28_not_null                                                                                               created IS NOT NULL
system              public             29_66_2_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_66_3_not_null                                                                                                transaction_fingerprint_id IS NOT NULL
system              public             29_66_4_not_null                                                                                                statement_id IS NOT NULL
system              public             29_66_5_not_null                                                                                                statement_fingerprint_id IS NOT NULL
system              public             29_67_10_not_null                                                                                               total_ranges IS NOT NULL
system              public             29_67_11_not_null                                                                                               total_live_data_bytes IS NOT NULL
system              public             29_67_12_not_null                                                                                               total_data_bytes IS NOT NULL
system              public             29_67_13_not_null                                                                                               perc_live_data IS NOT NULL
system              public             29_67_15_not_null                                                                                               last_updated IS NOT NULL
system              public             29_67_16_not_null                                                                                               table_type IS NOT NULL
system              public             29_67_17_not_null                                                                                               details IS NOT NULL
system              public             29_67_1_not_null                                                                                                db_id IS NOT NULL
system              public             29_67_2_not_null                                                                                                table_id IS NOT NULL
system              public             29_67_3_not_null                                                                                                db_name IS NOT NULL
system              public             29_67_4_not_null                                                                                                schema_name IS NOT NULL
system              public             29_67_5_not_null                                                                                                table_name IS NOT NULL
system              public             29_67_6_not_null                                                                                                total_columns IS NOT NULL
system              public             29_67_7_not_null                                                                                                total_indexes IS NOT NULL
system              public             29_67_8_not_null                                                                                                store_ids IS NOT NULL
system              public             29_67_9_not_null                                                                                                replication_size_bytes IS NOT NULL
system              public             29_68_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_68_2_not_null                                                                                                written IS NOT NULL
system              public             29_69_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_69_2_not_null                                                                                                written IS NOT NULL
system              public             29_6_1_not_null                                                                                                 name IS NOT NULL
system              public             29_6_2_not_null                                                                                                 value IS NOT NULL
system              public             29_6_3_not_null                                                                                                 lastUpdated IS NOT NULL
system              public             29_70_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_70_2_not_null                                                                                                written IS NOT NULL
system              public             29_70_3_not_null                                                                                                status IS NOT NULL
system              public             29_71_1_not_null                                                                                                job_id IS NOT NULL
system              public             29_71_2_not_null                                                                                                written IS NOT NULL
system              public             29_71_3_not_null                                                                                                kind IS NOT NULL
system              public             29_71_4_not_null                                                                                                message IS NOT NULL
system              public             29_72_1_not_null                                                                                                global_id IS NOT NULL
system              public             29_72_2_not_null                                                                                                transaction_id IS NOT NULL
system              public             29_72_4_not_null                                                                                                prepared IS NOT NULL
system              public             29_72_5_not_null                                                                                                owner IS NOT NULL
system              public             29_72_6_not_null                                                                                                database IS NOT NULL
system              public             29_7_1_not_null                                                                                                 value IS NOT NULL
system              public             29_8_1_not_null                                                                                                 id IS NOT NULL
system              public             29_9_1_not_null                                                                                                 crdb_region IS NOT NULL
system              public             check_bounds                                                                                                    ((start_key < end_key))
system              public             check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8  ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_plan_hash_transaction_fingerprint_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)))
system              public             check_crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8                                       ((crdb_internal_aggregated_ts_app_name_fingerprint_id_node_id_shard_8 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8)))
system              public             check_crdb_internal_created_at_database_id_index_id_table_id_shard_16                                           ((crdb_internal_created_at_database_id_index_id_table_id_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_end_time_start_time_shard_16                                                                ((crdb_internal_end_time_start_time_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_end_time_start_time_shard_16                                                                ((crdb_internal_end_time_start_time_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_crdb_internal_last_updated_table_id_shard_16                                                              ((crdb_internal_last_updated_table_id_shard_16 IN (0:::INT8, 1:::INT8, 2:::INT8, 3:::INT8, 4:::INT8, 5:::INT8, 6:::INT8, 7:::INT8, 8:::INT8, 9:::INT8, 10:::INT8, 11:::INT8, 12:::INT8, 13:::INT8, 14:::INT8, 15:::INT8)))
system              public             check_sampling_probability                                                                                      ((sampling_probability BETWEEN 0.0:::FLOAT8 AND 1.0:::FLOAT8))
system              public             check_singleton                                                                                                 ((singleton))
system              public             single_row                                                                                                      ((singleton))

statement ok
CREATE DATABASE constraint_db

statement ok
CREATE TABLE constraint_db.t1 (
  p FLOAT PRIMARY KEY,
  a INT UNIQUE CHECK (a > 4),
  CONSTRAINT c2 CHECK (a < 99)
)

statement ok
CREATE TABLE constraint_db.t2 (
    t1_ID INT,
    CONSTRAINT fk FOREIGN KEY (t1_ID) REFERENCES constraint_db.t1(a),
    INDEX (t1_ID)
)

statement ok
SET DATABASE = constraint_db

query TTTTTTTTT colnames
SELECT *
FROM information_schema.table_constraints
ORDER BY TABLE_NAME, CONSTRAINT_TYPE, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name     table_catalog  table_schema  table_name  constraint_type  is_deferrable  initially_deferred
constraint_db       public             117_118_1_not_null  constraint_db  public        t1          CHECK            NO             NO
constraint_db       public             c2                  constraint_db  public        t1          CHECK            NO             NO
constraint_db       public             check_a             constraint_db  public        t1          CHECK            NO             NO
constraint_db       public             t1_pkey             constraint_db  public        t1          PRIMARY KEY      NO             NO
constraint_db       public             t1_a_key            constraint_db  public        t1          UNIQUE           NO             NO
constraint_db       public             117_119_2_not_null  constraint_db  public        t2          CHECK            NO             NO
constraint_db       public             fk                  constraint_db  public        t2          FOREIGN KEY      NO             NO
constraint_db       public             t2_pkey             constraint_db  public        t2          PRIMARY KEY      NO             NO

query TTTT colnames
SELECT *
FROM information_schema.check_constraints
ORDER BY CONSTRAINT_CATALOG, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name     check_clause
constraint_db       public             117_118_1_not_null  p IS NOT NULL
constraint_db       public             c2                  ((a < 99:::INT8))
constraint_db       public             check_a             ((a > 4:::INT8))

query TTTTTTT colnames
SELECT *
FROM information_schema.constraint_column_usage
WHERE constraint_catalog = 'constraint_db'
ORDER BY TABLE_NAME, COLUMN_NAME, CONSTRAINT_NAME
----
table_catalog  table_schema  table_name  column_name  constraint_catalog  constraint_schema  constraint_name
constraint_db  public        t1          a            constraint_db       public             c2
constraint_db  public        t1          a            constraint_db       public             check_a
constraint_db  public        t1          a            constraint_db       public             fk
constraint_db  public        t1          a            constraint_db       public             t1_a_key
constraint_db  public        t1          p            constraint_db       public             t1_pkey
constraint_db  public        t2          rowid        constraint_db       public             t2_pkey

# Query issued by jOOQ in PostgresDatabase.loadCheckConstraints.
query TTTT colnames
SELECT tc.table_schema, tc.table_name, cc.constraint_name, cc.check_clause
FROM information_schema.table_constraints AS tc
JOIN information_schema.check_constraints AS cc
USING (constraint_catalog, constraint_schema, constraint_name)
WHERE tc.table_schema in ('public')
ORDER BY tc.table_schema, tc.table_name, cc.constraint_name
----
table_schema  table_name  constraint_name     check_clause
public        t1          117_118_1_not_null  p IS NOT NULL
public        t1          c2                  ((a < 99:::INT8))
public        t1          check_a             ((a > 4:::INT8))

statement ok
DROP DATABASE constraint_db CASCADE

## information_schema.columns

statement ok
SET DATABASE = test;

statement ok
CREATE TABLE t2(a smallint DEFAULT 0);

query TT colnames
select data_type, column_default from information_schema.columns where table_name = 't2' and column_name = 'a';
----
data_type  column_default
smallint   0

skipif config local-mixed-24.3
query TTTTI colnames
SELECT table_catalog, table_schema, table_name, column_name, ordinal_position
FROM system.information_schema.columns
WHERE table_schema != 'information_schema' AND table_schema != 'pg_catalog' AND table_schema != 'crdb_internal'
AND NOT (table_catalog = 'system' AND table_schema = 'public' AND table_name NOT IN ('locations', 'comments'))
ORDER BY 3,4
----
table_catalog  table_schema  table_name         column_name         ordinal_position
system         public        comments           comment             4
system         public        comments           object_id           2
system         public        comments           sub_id              3
system         public        comments           type                1
system         pg_extension  geography_columns  coord_dimension     5
system         pg_extension  geography_columns  f_geography_column  4
system         pg_extension  geography_columns  f_table_catalog     1
system         pg_extension  geography_columns  f_table_name        3
system         pg_extension  geography_columns  f_table_schema      2
system         pg_extension  geography_columns  srid                6
system         pg_extension  geography_columns  type                7
system         pg_extension  geometry_columns   coord_dimension     5
system         pg_extension  geometry_columns   f_geometry_column   4
system         pg_extension  geometry_columns   f_table_catalog     1
system         pg_extension  geometry_columns   f_table_name        3
system         pg_extension  geometry_columns   f_table_schema      2
system         pg_extension  geometry_columns   srid                6
system         pg_extension  geometry_columns   type                7
system         public        locations          latitude            3
system         public        locations          localityKey         1
system         public        locations          localityValue       2
system         public        locations          longitude           4
system         pg_extension  spatial_ref_sys    auth_name           2
system         pg_extension  spatial_ref_sys    auth_srid           3
system         pg_extension  spatial_ref_sys    proj4text           5
system         pg_extension  spatial_ref_sys    srid                1
system         pg_extension  spatial_ref_sys    srtext              4

statement ok
SET DATABASE = test

statement ok
CREATE TABLE with_defaults (a INT DEFAULT 9, b STRING DEFAULT 'default', c INT, d STRING)

query TTT colnames,rowsort
SELECT table_name, column_name, column_default
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'with_defaults'
----
table_name     column_name  column_default
with_defaults  a            9
with_defaults  b            'default'
with_defaults  c            NULL
with_defaults  d            NULL
with_defaults  rowid        unique_rowid()

statement ok
DROP TABLE with_defaults

statement ok
CREATE TABLE nullability (a INT NOT NULL, b STRING NOT NULL, c INT, d STRING)

query TTT colnames,rowsort
SELECT table_name, column_name, is_nullable
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'nullability'
----
table_name   column_name  is_nullable
nullability  a            NO
nullability  b            NO
nullability  c            YES
nullability  d            YES
nullability  rowid        NO

statement ok
DROP TABLE nullability

statement ok
CREATE TABLE data_types (
  a   INT,
  a2  INT2,
  a4  INT4,
  a8  INT8,
  b   FLOAT,
  b4  FLOAT4,
  br  REAL,
  c   DECIMAL,
  cp  DECIMAL(3),
  cps DECIMAL(3,2),
  d   STRING,
  dl  STRING COLLATE en,
  dc  CHAR,
  dc2 CHAR(2),
  dv  VARCHAR,
  dv2 VARCHAR(2),
  dq  "char",
  e   BYTES,
  f   TIMESTAMP,
  f6  TIMESTAMP(6),
  g   TIMESTAMPTZ,
  g6  TIMESTAMPTZ(6),
  h   BIT,
  h2  BIT(2),
  hv  VARBIT,
  hv2 VARBIT(2),
  i   INTERVAL,
  j   BOOL,
  k   OID,
  k2  REGCLASS,
  k3  REGNAMESPACE,
  k4  REGPROC,
  k5  REGPROCEDURE,
  k6  REGROLE,
  k7  REGTYPE,
  l   UUID,
  m   INT2[],
  m2  STRING[],
  m3  DECIMAL(3, 2)[],
  m4  VARCHAR(2)[] COLLATE en,
  n   INET,
  o   TIME,
  o6  TIME(6),
  p   JSONB,
  q   NAME
)

query TTTTTTTTTT colnames
SELECT table_name, column_name, data_type, crdb_sql_type, udt_catalog, udt_schema, udt_name, collation_catalog, collation_schema, collation_name
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'data_types'
ORDER BY column_name
----
table_name  column_name  data_type                    crdb_sql_type            udt_catalog  udt_schema  udt_name      collation_catalog  collation_schema  collation_name
data_types  a            bigint                       INT8                     test         pg_catalog  int8          NULL               NULL              NULL
data_types  a2           smallint                     INT2                     test         pg_catalog  int2          NULL               NULL              NULL
data_types  a4           integer                      INT4                     test         pg_catalog  int4          NULL               NULL              NULL
data_types  a8           bigint                       INT8                     test         pg_catalog  int8          NULL               NULL              NULL
data_types  b            double precision             FLOAT8                   test         pg_catalog  float8        NULL               NULL              NULL
data_types  b4           real                         FLOAT4                   test         pg_catalog  float4        NULL               NULL              NULL
data_types  br           real                         FLOAT4                   test         pg_catalog  float4        NULL               NULL              NULL
data_types  c            numeric                      DECIMAL                  test         pg_catalog  numeric       NULL               NULL              NULL
data_types  cp           numeric                      DECIMAL(3)               test         pg_catalog  numeric       NULL               NULL              NULL
data_types  cps          numeric                      DECIMAL(3,2)             test         pg_catalog  numeric       NULL               NULL              NULL
data_types  d            text                         STRING                   test         pg_catalog  text          NULL               NULL              NULL
data_types  dc           character                    CHAR                     test         pg_catalog  bpchar        NULL               NULL              NULL
data_types  dc2          character                    CHAR(2)                  test         pg_catalog  bpchar        NULL               NULL              NULL
data_types  dl           text                         STRING COLLATE en        test         pg_catalog  text          test               pg_catalog        en
data_types  dq           "char"                       "char"                   test         pg_catalog  char          NULL               NULL              NULL
data_types  dv           character varying            VARCHAR                  test         pg_catalog  varchar       NULL               NULL              NULL
data_types  dv2          character varying            VARCHAR(2)               test         pg_catalog  varchar       NULL               NULL              NULL
data_types  e            bytea                        BYTES                    test         pg_catalog  bytea         NULL               NULL              NULL
data_types  f            timestamp without time zone  TIMESTAMP                test         pg_catalog  timestamp     NULL               NULL              NULL
data_types  f6           timestamp without time zone  TIMESTAMP(6)             test         pg_catalog  timestamp     NULL               NULL              NULL
data_types  g            timestamp with time zone     TIMESTAMPTZ              test         pg_catalog  timestamptz   NULL               NULL              NULL
data_types  g6           timestamp with time zone     TIMESTAMPTZ(6)           test         pg_catalog  timestamptz   NULL               NULL              NULL
data_types  h            bit                          BIT                      test         pg_catalog  bit           NULL               NULL              NULL
data_types  h2           bit                          BIT(2)                   test         pg_catalog  bit           NULL               NULL              NULL
data_types  hv           bit varying                  VARBIT                   test         pg_catalog  varbit        NULL               NULL              NULL
data_types  hv2          bit varying                  VARBIT(2)                test         pg_catalog  varbit        NULL               NULL              NULL
data_types  i            interval                     INTERVAL                 test         pg_catalog  interval      NULL               NULL              NULL
data_types  j            boolean                      BOOL                     test         pg_catalog  bool          NULL               NULL              NULL
data_types  k            oid                          OID                      test         pg_catalog  oid           NULL               NULL              NULL
data_types  k2           regclass                     REGCLASS                 test         pg_catalog  regclass      NULL               NULL              NULL
data_types  k3           regnamespace                 REGNAMESPACE             test         pg_catalog  regnamespace  NULL               NULL              NULL
data_types  k4           regproc                      REGPROC                  test         pg_catalog  regproc       NULL               NULL              NULL
data_types  k5           regprocedure                 REGPROCEDURE             test         pg_catalog  regprocedure  NULL               NULL              NULL
data_types  k6           regrole                      REGROLE                  test         pg_catalog  regrole       NULL               NULL              NULL
data_types  k7           regtype                      REGTYPE                  test         pg_catalog  regtype       NULL               NULL              NULL
data_types  l            uuid                         UUID                     test         pg_catalog  uuid          NULL               NULL              NULL
data_types  m            ARRAY                        INT2[]                   test         pg_catalog  _int2         NULL               NULL              NULL
data_types  m2           ARRAY                        STRING[]                 test         pg_catalog  _text         NULL               NULL              NULL
data_types  m3           ARRAY                        DECIMAL(3,2)[]           test         pg_catalog  _numeric      NULL               NULL              NULL
data_types  m4           ARRAY                        VARCHAR(2)[] COLLATE en  test         pg_catalog  _varchar      NULL               NULL              NULL
data_types  n            inet                         INET                     test         pg_catalog  inet          NULL               NULL              NULL
data_types  o            time without time zone       TIME                     test         pg_catalog  time          NULL               NULL              NULL
data_types  o6           time without time zone       TIME(6)                  test         pg_catalog  time          NULL               NULL              NULL
data_types  p            jsonb                        JSONB                    test         pg_catalog  jsonb         NULL               NULL              NULL
data_types  q            name                         NAME                     test         pg_catalog  name          NULL               NULL              NULL
data_types  rowid        bigint                       INT8                     test         pg_catalog  int8          NULL               NULL              NULL

statement ok
DROP TABLE data_types

statement ok
CREATE TABLE computed (a INT, b INT AS (a + 1) STORED)

query TTTT colnames
SELECT column_name, is_generated, generation_expression, is_updatable
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'computed'
ORDER BY column_name
----
column_name  is_generated  generation_expression  is_updatable
a            NEVER         ·                      YES
b            ALWAYS        a + 1                  NO
rowid        NEVER         ·                      YES

statement ok
CREATE TABLE generated_as_identity (
  a INT,
  b INT GENERATED ALWAYS AS IDENTITY,
  c INT GENERATED BY DEFAULT AS IDENTITY
)

query TTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'generated_as_identity'
ORDER BY column_name
----
column_name  is_identity  identity_generation  is_nullable
a            NO           ·                    YES
b            YES          ALWAYS               NO
c            YES          BY DEFAULT           NO
rowid        NO           ·                    NO

statement ok
CREATE DATABASE test_identity

statement ok
SET DATABASE = test_identity

statement ok
CREATE TABLE add_generated_as_identity (
  a INT NOT NULL,
  b INT NOT NULL
)

statement ok
ALTER TABLE add_generated_as_identity ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY (START WITH 10 INCREMENT BY 2);

statement ok
ALTER TABLE add_generated_as_identity ALTER COLUMN b ADD GENERATED BY DEFAULT AS IDENTITY (START WITH 10 INCREMENT BY 2);

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'add_generated_as_identity'
ORDER BY column_name
----
column_name  is_identity  identity_generation  is_nullable  column_default                                               identity_start  identity_increment  identity_maximum     identity_minimum  identity_cycle
a            YES          ALWAYS               NO           nextval('public.add_generated_as_identity_a_seq'::REGCLASS)  10              2                   9223372036854775807  1                 NULL
b            YES          BY DEFAULT           NO           nextval('public.add_generated_as_identity_b_seq'::REGCLASS)  10              2                   9223372036854775807  1                 NULL
rowid        NO           ·                    NO           unique_rowid()                                               NULL            NULL                NULL                 NULL              NULL

statement ok
CREATE TABLE set_generated_as_identity (
  a INT GENERATED ALWAYS AS IDENTITY (START WITH 10),
  b INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10)
)

statement ok
ALTER TABLE set_generated_as_identity ALTER COLUMN a SET GENERATED BY DEFAULT;

statement ok
ALTER TABLE set_generated_as_identity ALTER COLUMN b SET GENERATED ALWAYS;

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'set_generated_as_identity'
ORDER BY column_name
----
column_name  is_identity  identity_generation  is_nullable  column_default                                               identity_start  identity_increment  identity_maximum     identity_minimum  identity_cycle
a            YES          BY DEFAULT           NO           nextval('public.set_generated_as_identity_a_seq'::REGCLASS)  10              1                   9223372036854775807  1                 NULL
b            YES          ALWAYS               NO           nextval('public.set_generated_as_identity_b_seq'::REGCLASS)  10              1                   9223372036854775807  1                 NULL
rowid        NO           ·                    NO           unique_rowid()                                               NULL            NULL                NULL                 NULL              NULL

statement ok
CREATE TABLE drop_generated_as_identity (a INT GENERATED ALWAYS AS IDENTITY (START WITH 10))

statement ok
ALTER TABLE drop_generated_as_identity ALTER COLUMN a DROP IDENTITY;

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'drop_generated_as_identity'
ORDER BY column_name
----
column_name  is_identity  identity_generation  is_nullable  column_default  identity_start  identity_increment  identity_maximum  identity_minimum  identity_cycle
a            NO           ·                    NO           NULL            NULL            NULL                NULL              NULL              NULL
rowid        NO           ·                    NO           unique_rowid()  NULL            NULL                NULL              NULL              NULL

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences ORDER BY sequence_name
----
sequence_catalog  sequence_schema  sequence_name                    data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value        increment  cycle_option
test_identity     public           add_generated_as_identity_a_seq  INT8       64                 2                        0              10           1              9223372036854775807  2          NO
test_identity     public           add_generated_as_identity_b_seq  INT8       64                 2                        0              10           1              9223372036854775807  2          NO
test_identity     public           set_generated_as_identity_a_seq  INT8       64                 2                        0              10           1              9223372036854775807  1          NO
test_identity     public           set_generated_as_identity_b_seq  INT8       64                 2                        0              10           1              9223372036854775807  1          NO

statement ok
CREATE TABLE alter_opts_generated_as_identity (a INT GENERATED ALWAYS AS IDENTITY (START WITH 2))

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'alter_opts_generated_as_identity' AND column_name = 'a'
----
column_name  is_identity  identity_generation  is_nullable  column_default                                                      identity_start  identity_increment  identity_maximum     identity_minimum  identity_cycle
a            YES          ALWAYS               NO           nextval('public.alter_opts_generated_as_identity_a_seq'::REGCLASS)  2               1                   9223372036854775807  1                 NULL

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences WHERE sequence_name = 'alter_opts_generated_as_identity_a_seq'
----
sequence_catalog  sequence_schema  sequence_name                           data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value        increment  cycle_option
test_identity     public           alter_opts_generated_as_identity_a_seq  INT8       64                 2                        0              2            1              9223372036854775807  1          NO

statement ok
ALTER TABLE alter_opts_generated_as_identity ALTER COLUMN a SET INCREMENT BY 2;

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences WHERE sequence_name = 'alter_opts_generated_as_identity_a_seq'
----
sequence_catalog  sequence_schema  sequence_name                           data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value        increment  cycle_option
test_identity     public           alter_opts_generated_as_identity_a_seq  INT8       64                 2                        0              2            1              9223372036854775807  2          NO

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'alter_opts_generated_as_identity' AND column_name = 'a'
----
column_name  is_identity  identity_generation  is_nullable  column_default                                                      identity_start  identity_increment  identity_maximum     identity_minimum  identity_cycle
a            YES          ALWAYS               NO           nextval('public.alter_opts_generated_as_identity_a_seq'::REGCLASS)  2               2                   9223372036854775807  1                 NULL

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences WHERE sequence_name = 'alter_opts_generated_as_identity_a_seq'
----
sequence_catalog  sequence_schema  sequence_name                           data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value        increment  cycle_option
test_identity     public           alter_opts_generated_as_identity_a_seq  INT8       64                 2                        0              2            1              9223372036854775807  2          NO

statement ok
ALTER TABLE alter_opts_generated_as_identity ALTER COLUMN a SET MAXVALUE 40 SET START WITH 2 SET CACHE 5 SET INCREMENT BY 2;

query TTTTTTTTTT colnames
SELECT column_name, is_identity, identity_generation, is_nullable, column_default, identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle
FROM information_schema.columns WHERE table_schema = 'public' AND table_name = 'alter_opts_generated_as_identity' AND column_name = 'a'
----
column_name  is_identity  identity_generation  is_nullable  column_default                                                      identity_start  identity_increment  identity_maximum  identity_minimum  identity_cycle
a            YES          ALWAYS               NO           nextval('public.alter_opts_generated_as_identity_a_seq'::REGCLASS)  2               2                   40                1                 NULL

query TTTTIIITTTTT colnames
SELECT * FROM information_schema.sequences WHERE sequence_name = 'alter_opts_generated_as_identity_a_seq'
----
sequence_catalog  sequence_schema  sequence_name                           data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value  increment  cycle_option
test_identity     public           alter_opts_generated_as_identity_a_seq  INT8       64                 2                        0              2            1              40             2          NO

statement ok
SET DATABASE = test

statement ok
CREATE TABLE char_len (
  a INT, b INT2, c INT4,
  d STRING, e STRING(12),
  dc CHAR, ec CHAR(12),
  dv VARCHAR, ev VARCHAR(12),
  dq "char",
  f FLOAT,
  g BIT, h BIT(12),
  i VARBIT, j VARBIT(12))

query TTII colnames,rowsort
SELECT table_name, column_name, character_maximum_length, character_octet_length
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'char_len'
----
table_name  column_name  character_maximum_length  character_octet_length
char_len    a            NULL                      NULL
char_len    b            NULL                      NULL
char_len    c            NULL                      NULL
char_len    d            NULL                      NULL
char_len    e            12                        48
char_len    dc           1                         4
char_len    ec           12                        48
char_len    dv           NULL                      NULL
char_len    ev           12                        48
char_len    dq           NULL                      NULL
char_len    f            NULL                      NULL
char_len    g            1                         NULL
char_len    h            12                        NULL
char_len    i            NULL                      NULL
char_len    j            12                        NULL
char_len    rowid        NULL                      NULL

statement ok
DROP TABLE char_len

statement ok
CREATE TABLE num_prec (a INT, b FLOAT, c FLOAT(23), d DECIMAL, e DECIMAL(12), f DECIMAL(12, 6), g BOOLEAN)

query TTIIII colnames,rowsort
SELECT table_name, column_name, numeric_precision, numeric_precision_radix, numeric_scale, datetime_precision
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'num_prec'
----
table_name  column_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision
num_prec    a            64                 2                        0              NULL
num_prec    b            53                 2                        NULL           NULL
num_prec    c            24                 2                        NULL           NULL
num_prec    d            NULL               10                       NULL           NULL
num_prec    e            12                 10                       0              NULL
num_prec    f            12                 10                       6              NULL
num_prec    g            NULL               NULL                     NULL           NULL
num_prec    rowid        64                 2                        0              NULL

statement ok
DROP TABLE num_prec

statement ok
CREATE TABLE time_prec (
  a TIME,
  b TIME(0),
  c TIMETZ,
  d TIMETZ(1),
  e TIMESTAMP,
  f TIMESTAMP(2),
  g TIMESTAMPTZ,
  h TIMESTAMPTZ(3),
  i INTERVAL,
  j INTERVAL(6))

query TTIIII colnames,rowsort
SELECT table_name, column_name, numeric_precision, numeric_precision_radix, numeric_scale, datetime_precision
FROM information_schema.columns
WHERE table_schema = 'public' AND table_name = 'time_prec'
----
table_name  column_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision
time_prec   a            NULL               NULL                     NULL           6
time_prec   b            NULL               NULL                     NULL           0
time_prec   c            NULL               NULL                     NULL           6
time_prec   d            NULL               NULL                     NULL           1
time_prec   e            NULL               NULL                     NULL           6
time_prec   f            NULL               NULL                     NULL           2
time_prec   g            NULL               NULL                     NULL           6
time_prec   h            NULL               NULL                     NULL           3
time_prec   i            NULL               NULL                     NULL           6
time_prec   j            NULL               NULL                     NULL           6
time_prec   rowid        64                 2                        0              NULL

statement ok
DROP TABLE time_prec

statement ok
CREATE TABLE t1 (
  id INT8 NULL,
  name STRING NULL,
  class STRING NULL,
  FAMILY "primary" (id, name, rowid)
)

query TTTTT colnames,rowsort
SELECT table_catalog, table_schema, table_name, column_name, column_comment
FROM information_schema.columns
WHERE table_name = 't1'
----
table_catalog  table_schema  table_name  column_name  column_comment
test           public        t1          id           NULL
test           public        t1          name         NULL
test           public        t1          class        NULL
test           public        t1          rowid        NULL

statement ok
COMMENT ON COLUMN public.t1.id IS 'identification'

statement ok
COMMENT ON COLUMN public.t1.name IS 'character'

query TTTTT colnames,rowsort
SELECT table_catalog, table_schema, table_name, column_name, column_comment
FROM information_schema.columns
WHERE table_name = 't1'
----
table_catalog  table_schema  table_name  column_name  column_comment
test           public        t1          id           identification
test           public        t1          name         character
test           public        t1          class        NULL
test           public        t1          rowid        NULL

query TTTTT colnames,rowsort
SELECT table_catalog, table_schema, table_name, column_name, column_comment
FROM information_schema.columns
WHERE table_name = 't1' AND column_comment != ''
----
table_catalog  table_schema  table_name  column_name  column_comment
test           public        t1          id           identification
test           public        t1          name         character

statement ok
DROP TABLE t1

## information_schema.key_column_usage
## information_schema.referential_constraints

statement ok
CREATE DATABASE constraint_column

statement ok
CREATE TABLE constraint_column.t1 (
  p FLOAT PRIMARY KEY,
  a INT UNIQUE,
  b INT,
  c INT CHECK(c > 0),
  UNIQUE INDEX index_key(b, c)
)

statement ok
CREATE TABLE constraint_column.t2 (
    t1_ID INT PRIMARY KEY,
    CONSTRAINT fk FOREIGN KEY (t1_ID) REFERENCES constraint_column.t1(a) ON DELETE RESTRICT
)

statement ok
CREATE TABLE constraint_column.t3 (
    a INT,
    b INT,
    CONSTRAINT fk2 FOREIGN KEY (a, b) REFERENCES constraint_column.t1(b, c) ON UPDATE CASCADE,
    INDEX (a, b)
)

statement ok
SET experimental_enable_unique_without_index_constraints = true

statement ok
CREATE TABLE constraint_column.t4 (
    a INT UNIQUE WITHOUT INDEX,
    b FLOAT,
    c STRING,
    UNIQUE WITHOUT INDEX (b, c)
)

statement ok
CREATE TABLE constraint_column.t5 (
    a INT REFERENCES constraint_column.t4(a) ON DELETE CASCADE,
    b FLOAT,
    c STRING,
    CONSTRAINT fk3 FOREIGN KEY (b, c) REFERENCES constraint_column.t4(b, c) MATCH FULL ON UPDATE RESTRICT
)

statement ok
SET DATABASE = constraint_column

query TTTTTTTII colnames
SELECT * FROM information_schema.key_column_usage WHERE constraint_schema = 'public' ORDER BY TABLE_NAME, CONSTRAINT_NAME, ORDINAL_POSITION
----
constraint_catalog  constraint_schema  constraint_name  table_catalog      table_schema  table_name  column_name  ordinal_position  position_in_unique_constraint
constraint_column   public             index_key        constraint_column  public        t1          b            1                 NULL
constraint_column   public             index_key        constraint_column  public        t1          c            2                 NULL
constraint_column   public             t1_a_key         constraint_column  public        t1          a            1                 NULL
constraint_column   public             t1_pkey          constraint_column  public        t1          p            1                 NULL
constraint_column   public             fk               constraint_column  public        t2          t1_id        1                 1
constraint_column   public             t2_pkey          constraint_column  public        t2          t1_id        1                 NULL
constraint_column   public             fk2              constraint_column  public        t3          a            1                 1
constraint_column   public             fk2              constraint_column  public        t3          b            2                 2
constraint_column   public             t3_pkey          constraint_column  public        t3          rowid        1                 NULL
constraint_column   public             t4_pkey          constraint_column  public        t4          rowid        1                 NULL
constraint_column   public             unique_a         constraint_column  public        t4          a            1                 NULL
constraint_column   public             unique_b_c       constraint_column  public        t4          b            1                 NULL
constraint_column   public             unique_b_c       constraint_column  public        t4          c            2                 NULL
constraint_column   public             fk3              constraint_column  public        t5          b            1                 1
constraint_column   public             fk3              constraint_column  public        t5          c            2                 2
constraint_column   public             t5_a_fkey        constraint_column  public        t5          a            1                 1
constraint_column   public             t5_pkey          constraint_column  public        t5          rowid        1                 NULL

query TTTTTTTTTTT colnames
SELECT * FROM information_schema.referential_constraints WHERE constraint_schema = 'public' ORDER BY TABLE_NAME, CONSTRAINT_NAME
----
constraint_catalog  constraint_schema  constraint_name  unique_constraint_catalog  unique_constraint_schema  unique_constraint_name  match_option  update_rule  delete_rule  table_name  referenced_table_name
constraint_column   public             fk               constraint_column          public                    t1_a_key                NONE          NO ACTION    RESTRICT     t2          t1
constraint_column   public             fk2              constraint_column          public                    index_key               NONE          CASCADE      NO ACTION    t3          t1
constraint_column   public             fk3              constraint_column          public                    unique_b_c              FULL          RESTRICT     NO ACTION    t5          t4
constraint_column   public             t5_a_fkey        constraint_column          public                    unique_a                NONE          NO ACTION    CASCADE      t5          t4

statement ok
DROP DATABASE constraint_column CASCADE

## information_schema.schema_privileges

statement ok
CREATE DATABASE other_db; SET DATABASE = other_db

statement ok
CREATE SCHEMA other_schema

query TTTTT colnames,rowsort
SELECT * FROM information_schema.schema_privileges
----
grantee  table_catalog  table_schema        privilege_type  is_grantable
public   other_db       crdb_internal       USAGE           NO
public   other_db       information_schema  USAGE           NO
admin    other_db       other_schema        ALL             YES
root     other_db       other_schema        ALL             YES
public   other_db       pg_catalog          USAGE           NO
public   other_db       pg_extension        USAGE           NO
admin    other_db       public              ALL             YES
public   other_db       public              CREATE          NO
public   other_db       public              USAGE           NO
root     other_db       public              ALL             YES

statement ok
GRANT CONNECT ON DATABASE other_db TO testuser

query TTTTT colnames,rowsort
SELECT * FROM information_schema.schema_privileges
----
grantee  table_catalog  table_schema        privilege_type  is_grantable
public   other_db       crdb_internal       USAGE           NO
public   other_db       information_schema  USAGE           NO
admin    other_db       other_schema        ALL             YES
root     other_db       other_schema        ALL             YES
public   other_db       pg_catalog          USAGE           NO
public   other_db       pg_extension        USAGE           NO
admin    other_db       public              ALL             YES
public   other_db       public              CREATE          NO
public   other_db       public              USAGE           NO
root     other_db       public              ALL             YES

statement ok
GRANT CREATE ON SCHEMA other_schema TO testuser

query TTTTT colnames,rowsort
SELECT * FROM information_schema.schema_privileges
----
grantee   table_catalog  table_schema        privilege_type  is_grantable
public    other_db       crdb_internal       USAGE           NO
public    other_db       information_schema  USAGE           NO
admin     other_db       other_schema        ALL             YES
root      other_db       other_schema        ALL             YES
testuser  other_db       other_schema        CREATE          NO
public    other_db       pg_catalog          USAGE           NO
public    other_db       pg_extension        USAGE           NO
admin     other_db       public              ALL             YES
public    other_db       public              CREATE          NO
public    other_db       public              USAGE           NO
root      other_db       public              ALL             YES

## information_schema.table_privileges and information_schema.role_table_grants

skipif config local-mixed-24.3
# root can see everything (filtering most of crdb_internal and system to avoid a brittle test)
query TTTTTTTT colnames,rowsort
SELECT * FROM system.information_schema.table_privileges 
WHERE 
  (table_schema <> 'crdb_internal' OR table_name = 'node_build_info') AND 
  NOT (table_catalog = 'system' AND table_schema = 'public' AND 'table_name' <> 'locations')
ORDER BY table_schema, table_name, table_schema, grantee, privilege_type
----
grantor  grantee  table_catalog  table_schema        table_name                             privilege_type  is_grantable  with_hierarchy
NULL     public   system         crdb_internal       node_build_info                        SELECT          NO            YES
NULL     public   system         information_schema  administrable_role_authorizations      SELECT          NO            YES
NULL     public   system         information_schema  applicable_roles                       SELECT          NO            YES
NULL     public   system         information_schema  attributes                             SELECT          NO            YES
NULL     public   system         information_schema  character_sets                         SELECT          NO            YES
NULL     public   system         information_schema  check_constraint_routine_usage         SELECT          NO            YES
NULL     public   system         information_schema  check_constraints                      SELECT          NO            YES
NULL     public   system         information_schema  collation_character_set_applicability  SELECT          NO            YES
NULL     public   system         information_schema  collations                             SELECT          NO            YES
NULL     public   system         information_schema  column_column_usage                    SELECT          NO            YES
NULL     public   system         information_schema  column_domain_usage                    SELECT          NO            YES
NULL     public   system         information_schema  column_options                         SELECT          NO            YES
NULL     public   system         information_schema  column_privileges                      SELECT          NO            YES
NULL     public   system         information_schema  column_statistics                      SELECT          NO            YES
NULL     public   system         information_schema  column_udt_usage                       SELECT          NO            YES
NULL     public   system         information_schema  columns                                SELECT          NO            YES
NULL     public   system         information_schema  columns_extensions                     SELECT          NO            YES
NULL     public   system         information_schema  constraint_column_usage                SELECT          NO            YES
NULL     public   system         information_schema  constraint_table_usage                 SELECT          NO            YES
NULL     public   system         information_schema  data_type_privileges                   SELECT          NO            YES
NULL     public   system         information_schema  domain_constraints                     SELECT          NO            YES
NULL     public   system         information_schema  domain_udt_usage                       SELECT          NO            YES
NULL     public   system         information_schema  domains                                SELECT          NO            YES
NULL     public   system         information_schema  element_types                          SELECT          NO            YES
NULL     public   system         information_schema  enabled_roles                          SELECT          NO            YES
NULL     public   system         information_schema  engines                                SELECT          NO            YES
NULL     public   system         information_schema  events                                 SELECT          NO            YES
NULL     public   system         information_schema  files                                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_data_wrapper_options           SELECT          NO            YES
NULL     public   system         information_schema  foreign_data_wrappers                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_server_options                 SELECT          NO            YES
NULL     public   system         information_schema  foreign_servers                        SELECT          NO            YES
NULL     public   system         information_schema  foreign_table_options                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_tables                         SELECT          NO            YES
NULL     public   system         information_schema  information_schema_catalog_name        SELECT          NO            YES
NULL     public   system         information_schema  key_column_usage                       SELECT          NO            YES
NULL     public   system         information_schema  keywords                               SELECT          NO            YES
NULL     public   system         information_schema  optimizer_trace                        SELECT          NO            YES
NULL     public   system         information_schema  parameters                             SELECT          NO            YES
NULL     public   system         information_schema  partitions                             SELECT          NO            YES
NULL     public   system         information_schema  plugins                                SELECT          NO            YES
NULL     public   system         information_schema  processlist                            SELECT          NO            YES
NULL     public   system         information_schema  profiling                              SELECT          NO            YES
NULL     public   system         information_schema  referential_constraints                SELECT          NO            YES
NULL     public   system         information_schema  resource_groups                        SELECT          NO            YES
NULL     public   system         information_schema  role_column_grants                     SELECT          NO            YES
NULL     public   system         information_schema  role_routine_grants                    SELECT          NO            YES
NULL     public   system         information_schema  role_table_grants                      SELECT          NO            YES
NULL     public   system         information_schema  role_udt_grants                        SELECT          NO            YES
NULL     public   system         information_schema  role_usage_grants                      SELECT          NO            YES
NULL     public   system         information_schema  routine_privileges                     SELECT          NO            YES
NULL     public   system         information_schema  routines                               SELECT          NO            YES
NULL     public   system         information_schema  schema_privileges                      SELECT          NO            YES
NULL     public   system         information_schema  schemata                               SELECT          NO            YES
NULL     public   system         information_schema  schemata_extensions                    SELECT          NO            YES
NULL     public   system         information_schema  sequences                              SELECT          NO            YES
NULL     public   system         information_schema  session_variables                      SELECT          NO            YES
NULL     public   system         information_schema  sql_features                           SELECT          NO            YES
NULL     public   system         information_schema  sql_implementation_info                SELECT          NO            YES
NULL     public   system         information_schema  sql_parts                              SELECT          NO            YES
NULL     public   system         information_schema  sql_sizing                             SELECT          NO            YES
NULL     public   system         information_schema  st_geometry_columns                    SELECT          NO            YES
NULL     public   system         information_schema  st_spatial_reference_systems           SELECT          NO            YES
NULL     public   system         information_schema  st_units_of_measure                    SELECT          NO            YES
NULL     public   system         information_schema  statistics                             SELECT          NO            YES
NULL     public   system         information_schema  table_constraints                      SELECT          NO            YES
NULL     public   system         information_schema  table_constraints_extensions           SELECT          NO            YES
NULL     public   system         information_schema  table_privileges                       SELECT          NO            YES
NULL     public   system         information_schema  tables                                 SELECT          NO            YES
NULL     public   system         information_schema  tables_extensions                      SELECT          NO            YES
NULL     public   system         information_schema  tablespaces                            SELECT          NO            YES
NULL     public   system         information_schema  tablespaces_extensions                 SELECT          NO            YES
NULL     public   system         information_schema  transforms                             SELECT          NO            YES
NULL     public   system         information_schema  triggered_update_columns               SELECT          NO            YES
NULL     public   system         information_schema  triggers                               SELECT          NO            YES
NULL     public   system         information_schema  type_privileges                        SELECT          NO            YES
NULL     public   system         information_schema  udt_privileges                         SELECT          NO            YES
NULL     public   system         information_schema  usage_privileges                       SELECT          NO            YES
NULL     public   system         information_schema  user_attributes                        SELECT          NO            YES
NULL     public   system         information_schema  user_defined_types                     SELECT          NO            YES
NULL     public   system         information_schema  user_mapping_options                   SELECT          NO            YES
NULL     public   system         information_schema  user_mappings                          SELECT          NO            YES
NULL     public   system         information_schema  user_privileges                        SELECT          NO            YES
NULL     public   system         information_schema  view_column_usage                      SELECT          NO            YES
NULL     public   system         information_schema  view_routine_usage                     SELECT          NO            YES
NULL     public   system         information_schema  view_table_usage                       SELECT          NO            YES
NULL     public   system         information_schema  views                                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_aggregate                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_am                                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_amop                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_amproc                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_attrdef                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_attribute                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_auth_members                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_authid                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_available_extension_versions        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_available_extensions                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_cast                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_class                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_collation                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_config                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_constraint                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_conversion                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_cursors                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_database                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_db_role_setting                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_default_acl                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_depend                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_description                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_enum                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_event_trigger                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_extension                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_file_settings                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_data_wrapper                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_server                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_table                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_group                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_hba_file_rules                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_index                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_indexes                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_inherits                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_init_privs                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_language                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_largeobject                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_largeobject_metadata                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_locks                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_matviews                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_namespace                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_opclass                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_operator                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_opfamily                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_partitioned_table                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_policies                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_policy                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_prepared_statements                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_prepared_xacts                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_proc                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication_rel                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication_tables                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_range                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_origin                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_origin_status           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_slots                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_rewrite                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_roles                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_rules                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_seclabel                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_seclabels                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_sequence                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_sequences                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_settings                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shadow                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shdepend                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shdescription                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shmem_allocations                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shseclabel                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_activity                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_all_indexes                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_all_tables                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_archiver                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_bgwriter                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_database                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_database_conflicts             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_gssapi                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_analyze               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_basebackup            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_cluster               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_create_index          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_vacuum                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_replication                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_slru                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_ssl                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_subscription                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_sys_indexes                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_sys_tables                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_functions                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_indexes                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_tables                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_wal_receiver                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_all_tables                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_sys_tables                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_user_functions            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_user_tables               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_indexes                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_sequences                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_tables                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_indexes                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_sequences                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_tables                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_indexes                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_sequences               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_tables                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic_ext                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic_ext_data                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stats                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stats_ext                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_subscription                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_subscription_rel                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_tables                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_tablespace                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_timezone_abbrevs                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_timezone_names                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_transform                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_trigger                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_config                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_config_map                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_dict                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_parser                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_template                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_type                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user_mapping                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user_mappings                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_views                               SELECT          NO            YES
NULL     public   system         pg_extension        geography_columns                      SELECT          NO            YES
NULL     public   system         pg_extension        geometry_columns                       SELECT          NO            YES
NULL     public   system         pg_extension        spatial_ref_sys                        SELECT          NO            YES

skipif config local-mixed-24.3
query TTTTTTTT colnames,rowsort
SELECT * FROM system.information_schema.role_table_grants 
WHERE 
(table_schema <> 'crdb_internal' OR table_name = 'node_build_info') 
AND NOT (table_schema = 'public' AND table_name <> 'locations');
----
grantor  grantee  table_catalog  table_schema        table_name                             privilege_type  is_grantable  with_hierarchy
NULL     public   system         crdb_internal       node_build_info                        SELECT          NO            YES
NULL     public   system         information_schema  administrable_role_authorizations      SELECT          NO            YES
NULL     public   system         information_schema  applicable_roles                       SELECT          NO            YES
NULL     public   system         information_schema  attributes                             SELECT          NO            YES
NULL     public   system         information_schema  character_sets                         SELECT          NO            YES
NULL     public   system         information_schema  check_constraint_routine_usage         SELECT          NO            YES
NULL     public   system         information_schema  check_constraints                      SELECT          NO            YES
NULL     public   system         information_schema  collation_character_set_applicability  SELECT          NO            YES
NULL     public   system         information_schema  collations                             SELECT          NO            YES
NULL     public   system         information_schema  column_column_usage                    SELECT          NO            YES
NULL     public   system         information_schema  column_domain_usage                    SELECT          NO            YES
NULL     public   system         information_schema  column_options                         SELECT          NO            YES
NULL     public   system         information_schema  column_privileges                      SELECT          NO            YES
NULL     public   system         information_schema  column_statistics                      SELECT          NO            YES
NULL     public   system         information_schema  column_udt_usage                       SELECT          NO            YES
NULL     public   system         information_schema  columns                                SELECT          NO            YES
NULL     public   system         information_schema  columns_extensions                     SELECT          NO            YES
NULL     public   system         information_schema  constraint_column_usage                SELECT          NO            YES
NULL     public   system         information_schema  constraint_table_usage                 SELECT          NO            YES
NULL     public   system         information_schema  data_type_privileges                   SELECT          NO            YES
NULL     public   system         information_schema  domain_constraints                     SELECT          NO            YES
NULL     public   system         information_schema  domain_udt_usage                       SELECT          NO            YES
NULL     public   system         information_schema  domains                                SELECT          NO            YES
NULL     public   system         information_schema  element_types                          SELECT          NO            YES
NULL     public   system         information_schema  enabled_roles                          SELECT          NO            YES
NULL     public   system         information_schema  engines                                SELECT          NO            YES
NULL     public   system         information_schema  events                                 SELECT          NO            YES
NULL     public   system         information_schema  files                                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_data_wrapper_options           SELECT          NO            YES
NULL     public   system         information_schema  foreign_data_wrappers                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_server_options                 SELECT          NO            YES
NULL     public   system         information_schema  foreign_servers                        SELECT          NO            YES
NULL     public   system         information_schema  foreign_table_options                  SELECT          NO            YES
NULL     public   system         information_schema  foreign_tables                         SELECT          NO            YES
NULL     public   system         information_schema  information_schema_catalog_name        SELECT          NO            YES
NULL     public   system         information_schema  key_column_usage                       SELECT          NO            YES
NULL     public   system         information_schema  keywords                               SELECT          NO            YES
NULL     public   system         information_schema  optimizer_trace                        SELECT          NO            YES
NULL     public   system         information_schema  parameters                             SELECT          NO            YES
NULL     public   system         information_schema  partitions                             SELECT          NO            YES
NULL     public   system         information_schema  plugins                                SELECT          NO            YES
NULL     public   system         information_schema  processlist                            SELECT          NO            YES
NULL     public   system         information_schema  profiling                              SELECT          NO            YES
NULL     public   system         information_schema  referential_constraints                SELECT          NO            YES
NULL     public   system         information_schema  resource_groups                        SELECT          NO            YES
NULL     public   system         information_schema  role_column_grants                     SELECT          NO            YES
NULL     public   system         information_schema  role_routine_grants                    SELECT          NO            YES
NULL     public   system         information_schema  role_table_grants                      SELECT          NO            YES
NULL     public   system         information_schema  role_udt_grants                        SELECT          NO            YES
NULL     public   system         information_schema  role_usage_grants                      SELECT          NO            YES
NULL     public   system         information_schema  routine_privileges                     SELECT          NO            YES
NULL     public   system         information_schema  routines                               SELECT          NO            YES
NULL     public   system         information_schema  schema_privileges                      SELECT          NO            YES
NULL     public   system         information_schema  schemata                               SELECT          NO            YES
NULL     public   system         information_schema  schemata_extensions                    SELECT          NO            YES
NULL     public   system         information_schema  sequences                              SELECT          NO            YES
NULL     public   system         information_schema  session_variables                      SELECT          NO            YES
NULL     public   system         information_schema  sql_features                           SELECT          NO            YES
NULL     public   system         information_schema  sql_implementation_info                SELECT          NO            YES
NULL     public   system         information_schema  sql_parts                              SELECT          NO            YES
NULL     public   system         information_schema  sql_sizing                             SELECT          NO            YES
NULL     public   system         information_schema  st_geometry_columns                    SELECT          NO            YES
NULL     public   system         information_schema  st_spatial_reference_systems           SELECT          NO            YES
NULL     public   system         information_schema  st_units_of_measure                    SELECT          NO            YES
NULL     public   system         information_schema  statistics                             SELECT          NO            YES
NULL     public   system         information_schema  table_constraints                      SELECT          NO            YES
NULL     public   system         information_schema  table_constraints_extensions           SELECT          NO            YES
NULL     public   system         information_schema  table_privileges                       SELECT          NO            YES
NULL     public   system         information_schema  tables                                 SELECT          NO            YES
NULL     public   system         information_schema  tables_extensions                      SELECT          NO            YES
NULL     public   system         information_schema  tablespaces                            SELECT          NO            YES
NULL     public   system         information_schema  tablespaces_extensions                 SELECT          NO            YES
NULL     public   system         information_schema  transforms                             SELECT          NO            YES
NULL     public   system         information_schema  triggered_update_columns               SELECT          NO            YES
NULL     public   system         information_schema  triggers                               SELECT          NO            YES
NULL     public   system         information_schema  type_privileges                        SELECT          NO            YES
NULL     public   system         information_schema  udt_privileges                         SELECT          NO            YES
NULL     public   system         information_schema  usage_privileges                       SELECT          NO            YES
NULL     public   system         information_schema  user_attributes                        SELECT          NO            YES
NULL     public   system         information_schema  user_defined_types                     SELECT          NO            YES
NULL     public   system         information_schema  user_mapping_options                   SELECT          NO            YES
NULL     public   system         information_schema  user_mappings                          SELECT          NO            YES
NULL     public   system         information_schema  user_privileges                        SELECT          NO            YES
NULL     public   system         information_schema  view_column_usage                      SELECT          NO            YES
NULL     public   system         information_schema  view_routine_usage                     SELECT          NO            YES
NULL     public   system         information_schema  view_table_usage                       SELECT          NO            YES
NULL     public   system         information_schema  views                                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_aggregate                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_am                                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_amop                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_amproc                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_attrdef                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_attribute                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_auth_members                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_authid                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_available_extension_versions        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_available_extensions                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_cast                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_class                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_collation                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_config                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_constraint                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_conversion                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_cursors                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_database                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_db_role_setting                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_default_acl                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_depend                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_description                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_enum                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_event_trigger                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_extension                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_file_settings                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_data_wrapper                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_server                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_foreign_table                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_group                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_hba_file_rules                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_index                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_indexes                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_inherits                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_init_privs                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_language                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_largeobject                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_largeobject_metadata                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_locks                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_matviews                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_namespace                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_opclass                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_operator                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_opfamily                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_partitioned_table                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_policies                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_policy                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_prepared_statements                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_prepared_xacts                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_proc                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication_rel                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_publication_tables                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_range                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_origin                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_origin_status           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_replication_slots                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_rewrite                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_roles                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_rules                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_seclabel                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_seclabels                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_sequence                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_sequences                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_settings                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shadow                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shdepend                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shdescription                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shmem_allocations                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_shseclabel                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_activity                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_all_indexes                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_all_tables                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_archiver                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_bgwriter                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_database                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_database_conflicts             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_gssapi                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_analyze               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_basebackup            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_cluster               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_create_index          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_progress_vacuum                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_replication                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_slru                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_ssl                            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_subscription                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_sys_indexes                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_sys_tables                     SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_functions                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_indexes                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_user_tables                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_wal_receiver                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_all_tables                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_sys_tables                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_user_functions            SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stat_xact_user_tables               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_indexes                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_sequences                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_all_tables                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_indexes                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_sequences                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_sys_tables                   SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_indexes                 SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_sequences               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statio_user_tables                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic_ext                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_statistic_ext_data                  SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stats                               SELECT          NO            YES
NULL     public   system         pg_catalog          pg_stats_ext                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_subscription                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_subscription_rel                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_tables                              SELECT          NO            YES
NULL     public   system         pg_catalog          pg_tablespace                          SELECT          NO            YES
NULL     public   system         pg_catalog          pg_timezone_abbrevs                    SELECT          NO            YES
NULL     public   system         pg_catalog          pg_timezone_names                      SELECT          NO            YES
NULL     public   system         pg_catalog          pg_transform                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_trigger                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_config                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_config_map                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_dict                             SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_parser                           SELECT          NO            YES
NULL     public   system         pg_catalog          pg_ts_template                         SELECT          NO            YES
NULL     public   system         pg_catalog          pg_type                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user                                SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user_mapping                        SELECT          NO            YES
NULL     public   system         pg_catalog          pg_user_mappings                       SELECT          NO            YES
NULL     public   system         pg_catalog          pg_views                               SELECT          NO            YES
NULL     public   system         pg_extension        geography_columns                      SELECT          NO            YES
NULL     public   system         pg_extension        geometry_columns                       SELECT          NO            YES
NULL     public   system         pg_extension        spatial_ref_sys                        SELECT          NO            YES
NULL     admin    system         public              locations                              DELETE          YES           NO
NULL     admin    system         public              locations                              INSERT          YES           NO
NULL     admin    system         public              locations                              SELECT          YES           YES
NULL     admin    system         public              locations                              UPDATE          YES           NO
NULL     root     system         public              locations                              DELETE          YES           NO
NULL     root     system         public              locations                              INSERT          YES           NO
NULL     root     system         public              locations                              SELECT          YES           YES
NULL     root     system         public              locations                              UPDATE          YES           NO

statement ok
USE other_db;

statement ok
ALTER DEFAULT PRIVILEGES GRANT SELECT ON TABLES TO testuser;

statement ok
CREATE TABLE other_db.xyz (i INT)

statement ok
USE test;

statement ok
CREATE VIEW other_db.abc AS SELECT i from other_db.xyz

query TTTTTTTT colnames,rowsort
SELECT * FROM other_db.information_schema.table_privileges WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

query TTTTTTTT colnames,rowsort
SELECT * FROM other_db.information_schema.role_table_grants WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

statement ok
GRANT UPDATE ON other_db.xyz TO testuser

query TTTTTTTT colnames,rowsort
SELECT * FROM other_db.information_schema.table_privileges WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     testuser  other_db       public        xyz         UPDATE          NO            NO
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

query TTTTTTTT colnames,rowsort
SELECT * FROM other_db.information_schema.role_table_grants WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     testuser  other_db       public        xyz         UPDATE          NO            NO
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

# testuser can read permissions as well
user testuser

statement ok
SET DATABASE = other_db

query TTTTTTTT colnames,rowsort
SELECT * FROM information_schema.table_privileges WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     testuser  other_db       public        xyz         UPDATE          NO            NO
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

query TTTTTTTT colnames,rowsort
SELECT * FROM information_schema.role_table_grants WHERE TABLE_SCHEMA = 'public'
----
grantor  grantee   table_catalog  table_schema  table_name  privilege_type  is_grantable  with_hierarchy
NULL     admin     other_db       public        xyz         ALL             YES           NO
NULL     root      other_db       public        xyz         ALL             YES           NO
NULL     testuser  other_db       public        xyz         SELECT          NO            YES
NULL     testuser  other_db       public        xyz         UPDATE          NO            NO
NULL     admin     other_db       public        abc         ALL             YES           NO
NULL     root      other_db       public        abc         ALL             YES           NO
NULL     testuser  other_db       public        abc         SELECT          NO            YES

statement ok
SET DATABASE = test

user root

## information_schema.statistics

statement ok
CREATE TABLE other_db.teststatics(id INT PRIMARY KEY, c INT, d INT, e STRING, INDEX idx_c(c), UNIQUE INDEX idx_cd(c,d))

query TTTTTTITIITTTTF colnames
SELECT * FROM other_db.information_schema.statistics WHERE table_schema='public' AND table_name='teststatics' ORDER BY INDEX_SCHEMA,INDEX_NAME,SEQ_IN_INDEX
----
table_catalog  table_schema  table_name   non_unique  index_schema  index_name        seq_in_index  column_name  COLLATION  cardinality  direction  storing  implicit  is_visible  visibility
other_db       public        teststatics  YES         public        idx_c             1             c            NULL       NULL         ASC        NO       NO        YES         1
other_db       public        teststatics  YES         public        idx_c             2             id           NULL       NULL         ASC        NO       YES       YES         1
other_db       public        teststatics  NO          public        idx_cd            1             c            NULL       NULL         ASC        NO       NO        YES         1
other_db       public        teststatics  NO          public        idx_cd            2             d            NULL       NULL         ASC        NO       NO        YES         1
other_db       public        teststatics  NO          public        idx_cd            3             id           NULL       NULL         ASC        YES      YES       YES         1
other_db       public        teststatics  NO          public        teststatics_pkey  1             id           NULL       NULL         ASC        NO       NO        YES         1
other_db       public        teststatics  NO          public        teststatics_pkey  2             c            NULL       NULL         N/A        YES      NO        YES         1
other_db       public        teststatics  NO          public        teststatics_pkey  3             d            NULL       NULL         N/A        YES      NO        YES         1
other_db       public        teststatics  NO          public        teststatics_pkey  4             e            NULL       NULL         N/A        YES      NO        YES         1

# Verify information_schema.views
statement ok
CREATE VIEW other_db.v_xyz AS SELECT i FROM other_db.xyz

query TTTTT colnames
SELECT TABLE_CATALOG, TABLE_SCHEMA, TABLE_NAME, VIEW_DEFINITION, CHECK_OPTION
FROM other_db.information_schema.views
WHERE TABLE_NAME='v_xyz'
----
table_catalog  table_schema  table_name  view_definition                    check_option
other_db       public        v_xyz       SELECT i FROM other_db.public.xyz  NULL

query TTTTT colnames
SELECT IS_UPDATABLE, IS_INSERTABLE_INTO, IS_TRIGGER_UPDATABLE, IS_TRIGGER_DELETABLE, IS_TRIGGER_INSERTABLE_INTO
FROM other_db.information_schema.views
WHERE TABLE_NAME='v_xyz'
----
is_updatable  is_insertable_into  is_trigger_updatable  is_trigger_deletable  is_trigger_insertable_into
NO            NO                  NO                    NO                    NO

statement ok
SET DATABASE = 'test'

statement ok
DROP DATABASE other_db CASCADE

#Verify  information_schema.user_privileges

query TTTT colnames,rowsort
SELECT * FROM information_schema.user_privileges ORDER BY grantee,privilege_type
----
grantee  table_catalog  privilege_type  is_grantable
admin    test           ALL             NULL
admin    test           BACKUP          NULL
admin    test           CHANGEFEED      NULL
admin    test           CREATE          NULL
admin    test           DELETE          NULL
admin    test           DROP            NULL
admin    test           INSERT          NULL
admin    test           SELECT          NULL
admin    test           TRIGGER         NULL
admin    test           UPDATE          NULL
admin    test           ZONECONFIG      NULL
root     test           ALL             NULL
root     test           BACKUP          NULL
root     test           CHANGEFEED      NULL
root     test           CREATE          NULL
root     test           DELETE          NULL
root     test           DROP            NULL
root     test           INSERT          NULL
root     test           SELECT          NULL
root     test           TRIGGER         NULL
root     test           UPDATE          NULL
root     test           ZONECONFIG      NULL

# information_schema.sequences

statement ok
SET DATABASE = test

query TTTTIIITTTTT rowsort
SELECT * FROM information_schema.sequences
----
test  public  generated_as_identity_b_seq  INT8  64  2  0  1  1  9223372036854775807  1  NO
test  public  generated_as_identity_c_seq  INT8  64  2  0  1  1  9223372036854775807  1  NO

statement ok
CREATE SEQUENCE test_seq

statement ok
CREATE SEQUENCE test_seq_2 INCREMENT -1 MINVALUE 5 MAXVALUE 1000 START WITH 15

statement ok
CREATE SEQUENCE test_seq_3 AS smallint

statement ok
CREATE SEQUENCE test_seq_4 AS integer 

statement ok
CREATE SEQUENCE test_seq_5 AS bigint

statement ok
CREATE SEQUENCE test_seq_6 AS INT2 

statement ok
CREATE SEQUENCE test_seq_7 AS INT4

statement ok
CREATE SEQUENCE test_seq_8 AS INT8 

query TTTTIIITTTTT colnames,rowsort
SELECT * FROM information_schema.sequences
----
sequence_catalog  sequence_schema  sequence_name                data_type  numeric_precision  numeric_precision_radix  numeric_scale  start_value  minimum_value  maximum_value        increment  cycle_option
test              public           generated_as_identity_b_seq  INT8       64                 2                        0              1            1              9223372036854775807  1          NO
test              public           generated_as_identity_c_seq  INT8       64                 2                        0              1            1              9223372036854775807  1          NO
test              public           test_seq                     INT8       64                 2                        0              1            1              9223372036854775807  1          NO
test              public           test_seq_2                   INT8       64                 2                        0              15           5              1000                 -1         NO
test              public           test_seq_3                   INT2       16                 2                        0              1            1              32767                1          NO
test              public           test_seq_4                   INT8       64                 2                        0              1            1              9223372036854775807  1          NO
test              public           test_seq_5                   INT8       64                 2                        0              1            1              9223372036854775807  1          NO
test              public           test_seq_6                   INT2       16                 2                        0              1            1              32767                1          NO
test              public           test_seq_7                   INT4       32                 2                        0              1            1              2147483647           1          NO
test              public           test_seq_8                   INT8       64                 2                        0              1            1              9223372036854775807  1          NO

statement ok
CREATE DATABASE other_db

statement ok
SET DATABASE = other_db

# Sequences in one database can't be seen from another database.

query TTTTIIITTTTT
SELECT * FROM information_schema.sequences
----

statement ok
SET DATABASE = test

statement ok
DROP DATABASE other_db CASCADE

# test information_schema.column_privileges
query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.column_privileges
----
column_name     data_type  is_nullable  column_default  generation_expression  indices  is_hidden
grantor         STRING     true         NULL            ·                      {}       false
grantee         STRING     false        NULL            ·                      {}       false
table_catalog   STRING     false        NULL            ·                      {}       false
table_schema    STRING     false        NULL            ·                      {}       false
table_name      STRING     false        NULL            ·                      {}       false
column_name     STRING     false        NULL            ·                      {}       false
privilege_type  STRING     false        NULL            ·                      {}       false
is_grantable    STRING     true         NULL            ·                      {}       false


# test information_schema.routines
query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.routines
----
column_name                          data_type    is_nullable  column_default  generation_expression  indices  is_hidden
specific_catalog                     STRING       true         NULL            ·                      {}       false
specific_schema                      STRING       true         NULL            ·                      {}       false
specific_name                        STRING       true         NULL            ·                      {}       false
routine_catalog                      STRING       true         NULL            ·                      {}       false
routine_schema                       STRING       true         NULL            ·                      {}       false
routine_name                         STRING       true         NULL            ·                      {}       false
routine_type                         STRING       true         NULL            ·                      {}       false
module_catalog                       STRING       true         NULL            ·                      {}       false
module_schema                        STRING       true         NULL            ·                      {}       false
module_name                          STRING       true         NULL            ·                      {}       false
udt_catalog                          STRING       true         NULL            ·                      {}       false
udt_schema                           STRING       true         NULL            ·                      {}       false
udt_name                             STRING       true         NULL            ·                      {}       false
data_type                            STRING       true         NULL            ·                      {}       false
character_maximum_length             INT8         true         NULL            ·                      {}       false
character_octet_length               INT8         true         NULL            ·                      {}       false
character_set_catalog                STRING       true         NULL            ·                      {}       false
character_set_schema                 STRING       true         NULL            ·                      {}       false
character_set_name                   STRING       true         NULL            ·                      {}       false
collation_catalog                    STRING       true         NULL            ·                      {}       false
collation_schema                     STRING       true         NULL            ·                      {}       false
collation_name                       STRING       true         NULL            ·                      {}       false
numeric_precision                    INT8         true         NULL            ·                      {}       false
numeric_precision_radix              INT8         true         NULL            ·                      {}       false
numeric_scale                        INT8         true         NULL            ·                      {}       false
datetime_precision                   INT8         true         NULL            ·                      {}       false
interval_type                        STRING       true         NULL            ·                      {}       false
interval_precision                   INT8         true         NULL            ·                      {}       false
type_udt_catalog                     STRING       true         NULL            ·                      {}       false
type_udt_schema                      STRING       true         NULL            ·                      {}       false
type_udt_name                        STRING       true         NULL            ·                      {}       false
scope_catalog                        STRING       true         NULL            ·                      {}       false
scope_schema                         STRING       true         NULL            ·                      {}       false
scope_name                           STRING       true         NULL            ·                      {}       false
maximum_cardinality                  INT8         true         NULL            ·                      {}       false
dtd_identifier                       STRING       true         NULL            ·                      {}       false
routine_body                         STRING       true         NULL            ·                      {}       false
routine_definition                   STRING       true         NULL            ·                      {}       false
external_name                        STRING       true         NULL            ·                      {}       false
external_language                    STRING       true         NULL            ·                      {}       false
parameter_style                      STRING       true         NULL            ·                      {}       false
is_deterministic                     STRING       true         NULL            ·                      {}       false
sql_data_access                      STRING       true         NULL            ·                      {}       false
is_null_call                         STRING       true         NULL            ·                      {}       false
sql_path                             STRING       true         NULL            ·                      {}       false
schema_level_routine                 STRING       true         NULL            ·                      {}       false
max_dynamic_result_sets              INT8         true         NULL            ·                      {}       false
is_user_defined_cast                 STRING       true         NULL            ·                      {}       false
is_implicitly_invocable              STRING       true         NULL            ·                      {}       false
security_type                        STRING       true         NULL            ·                      {}       false
to_sql_specific_catalog              STRING       true         NULL            ·                      {}       false
to_sql_specific_schema               STRING       true         NULL            ·                      {}       false
to_sql_specific_name                 STRING       true         NULL            ·                      {}       false
as_locator                           STRING       true         NULL            ·                      {}       false
created                              TIMESTAMPTZ  true         NULL            ·                      {}       false
last_altered                         TIMESTAMPTZ  true         NULL            ·                      {}       false
new_savepoint_level                  STRING       true         NULL            ·                      {}       false
is_udt_dependent                     STRING       true         NULL            ·                      {}       false
result_cast_from_data_type           STRING       true         NULL            ·                      {}       false
result_cast_as_locator               STRING       true         NULL            ·                      {}       false
result_cast_char_max_length          INT8         true         NULL            ·                      {}       false
result_cast_char_octet_length        INT8         true         NULL            ·                      {}       false
result_cast_char_set_catalog         STRING       true         NULL            ·                      {}       false
result_cast_char_set_schema          STRING       true         NULL            ·                      {}       false
result_cast_char_set_name            STRING       true         NULL            ·                      {}       false
result_cast_collation_catalog        STRING       true         NULL            ·                      {}       false
result_cast_collation_schema         STRING       true         NULL            ·                      {}       false
result_cast_collation_name           STRING       true         NULL            ·                      {}       false
result_cast_numeric_precision        INT8         true         NULL            ·                      {}       false
result_cast_numeric_precision_radix  INT8         true         NULL            ·                      {}       false
result_cast_numeric_scale            INT8         true         NULL            ·                      {}       false
result_cast_datetime_precision       INT8         true         NULL            ·                      {}       false
result_cast_interval_type            STRING       true         NULL            ·                      {}       false
result_cast_interval_precision       INT8         true         NULL            ·                      {}       false
result_cast_type_udt_catalog         STRING       true         NULL            ·                      {}       false
result_cast_type_udt_schema          STRING       true         NULL            ·                      {}       false
result_cast_type_udt_name            STRING       true         NULL            ·                      {}       false
result_cast_scope_catalog            STRING       true         NULL            ·                      {}       false
result_cast_scope_schema             STRING       true         NULL            ·                      {}       false
result_cast_scope_name               STRING       true         NULL            ·                      {}       false
result_cast_maximum_cardinality      INT8         true         NULL            ·                      {}       false
result_cast_dtd_identifier           STRING       true         NULL            ·                      {}       false

query TTTTTTTTTTTTTTTIITTTTTTIIIITTTTTTTITTTTTTTTTTTITTTTTTTTTTTTTITTTTTTTIIITTITTTTTTIT colnames,rowsort
SELECT * FROM information_schema.routines WHERE routine_name = 'pg_get_functiondef'
----
specific_catalog  specific_schema  specific_name            routine_catalog  routine_schema  routine_name        routine_type  module_catalog  module_schema  module_name  udt_catalog  udt_schema  udt_name  data_type  character_maximum_length  character_octet_length  character_set_catalog  character_set_schema  character_set_name  collation_catalog  collation_schema  collation_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision  interval_type  interval_precision  type_udt_catalog  type_udt_schema  type_udt_name  scope_catalog  scope_schema  scope_name  maximum_cardinality  dtd_identifier  routine_body  routine_definition  external_name  external_language  parameter_style  is_deterministic  sql_data_access  is_null_call  sql_path  schema_level_routine  max_dynamic_result_sets  is_user_defined_cast  is_implicitly_invocable  security_type  to_sql_specific_catalog  to_sql_specific_schema  to_sql_specific_name  as_locator  created  last_altered  new_savepoint_level  is_udt_dependent  result_cast_from_data_type  result_cast_as_locator  result_cast_char_max_length  result_cast_char_octet_length  result_cast_char_set_catalog  result_cast_char_set_schema  result_cast_char_set_name  result_cast_collation_catalog  result_cast_collation_schema  result_cast_collation_name  result_cast_numeric_precision  result_cast_numeric_precision_radix  result_cast_numeric_scale  result_cast_datetime_precision  result_cast_interval_type  result_cast_interval_precision  result_cast_type_udt_catalog  result_cast_type_udt_schema  result_cast_type_udt_name  result_cast_scope_catalog  result_cast_scope_schema  result_cast_scope_name  result_cast_maximum_cardinality  result_cast_dtd_identifier
test              pg_catalog       pg_get_functiondef_2035  test             pg_catalog      pg_get_functiondef  FUNCTION      NULL            NULL           NULL         NULL         NULL        NULL      text       NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            NULL               NULL                     NULL           NULL                NULL           NULL                test              pg_catalog       text           NULL           NULL          NULL        NULL                 0               EXTERNAL      NULL                NULL           INTERNAL           GENERAL          NO                MODIFIES         NO            NULL      YES                   0                        NULL                  NULL                     INVOKER        NULL                     NULL                    NULL                  NO          NULL     NULL          NULL                 NO                NULL                        NULL                    NULL                         NULL                           NULL                          NULL                         NULL                       NULL                           NULL                          NULL                        NULL                           NULL                                 NULL                       NULL                            NULL                       NULL                            NULL                          NULL                         NULL                       NULL                       NULL                      NULL                    NULL                             NULL


# test information_schema.parameters
query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.parameters
----
column_name               data_type  is_nullable  column_default  generation_expression  indices  is_hidden
specific_catalog          STRING     true         NULL            ·                      {}       false
specific_schema           STRING     true         NULL            ·                      {}       false
specific_name             STRING     true         NULL            ·                      {}       false
ordinal_position          INT8       true         NULL            ·                      {}       false
parameter_mode            STRING     true         NULL            ·                      {}       false
is_result                 STRING     true         NULL            ·                      {}       false
as_locator                STRING     true         NULL            ·                      {}       false
parameter_name            STRING     true         NULL            ·                      {}       false
data_type                 STRING     true         NULL            ·                      {}       false
character_maximum_length  INT8       true         NULL            ·                      {}       false
character_octet_length    INT8       true         NULL            ·                      {}       false
character_set_catalog     STRING     true         NULL            ·                      {}       false
character_set_schema      STRING     true         NULL            ·                      {}       false
character_set_name        STRING     true         NULL            ·                      {}       false
collation_catalog         STRING     true         NULL            ·                      {}       false
collation_schema          STRING     true         NULL            ·                      {}       false
collation_name            STRING     true         NULL            ·                      {}       false
numeric_precision         INT8       true         NULL            ·                      {}       false
numeric_precision_radix   INT8       true         NULL            ·                      {}       false
numeric_scale             INT8       true         NULL            ·                      {}       false
datetime_precision        INT8       true         NULL            ·                      {}       false
interval_type             STRING     true         NULL            ·                      {}       false
interval_precision        INT8       true         NULL            ·                      {}       false
udt_catalog               STRING     true         NULL            ·                      {}       false
udt_schema                STRING     true         NULL            ·                      {}       false
udt_name                  STRING     true         NULL            ·                      {}       false
scope_catalog             STRING     true         NULL            ·                      {}       false
scope_schema              STRING     true         NULL            ·                      {}       false
scope_name                STRING     true         NULL            ·                      {}       false
maximum_cardinality       INT8       true         NULL            ·                      {}       false
dtd_identifier            STRING     true         NULL            ·                      {}       false
parameter_default         STRING     true         NULL            ·                      {}       false

query TTTITTTTTIITTTTTTIIIITITTTTTTITT colnames
SELECT * FROM information_schema.parameters WHERE specific_name LIKE 'get_byte%' ORDER BY specific_name, ordinal_position
----
specific_catalog  specific_schema  specific_name  ordinal_position  parameter_mode  is_result  as_locator  parameter_name  data_type  character_maximum_length  character_octet_length  character_set_catalog  character_set_schema  character_set_name  collation_catalog  collation_schema  collation_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision  interval_type  interval_precision  udt_catalog  udt_schema  udt_name  scope_catalog  scope_schema  scope_name  maximum_cardinality  dtd_identifier  parameter_default
test              pg_catalog       get_byte_854   1                 IN              NO         NO          NULL            bytea      NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            NULL               NULL                     NULL           NULL                NULL           NULL                test         pg_catalog  bytea     NULL           NULL          NULL        NULL                 1               NULL
test              pg_catalog       get_byte_854   2                 IN              NO         NO          NULL            bigint     NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            NULL               NULL                     NULL           NULL                NULL           NULL                test         pg_catalog  int8      NULL           NULL          NULL        NULL                 2               NULL

query TTTTTTTT colnames,rowsort
SELECT * FROM system.information_schema.column_privileges WHERE table_name = 'eventlog'
----
grantor  grantee  table_catalog  table_schema  table_name  column_name  privilege_type  is_grantable
NULL     admin    system         public        eventlog    timestamp    SELECT          NULL
NULL     admin    system         public        eventlog    eventType    SELECT          NULL
NULL     admin    system         public        eventlog    targetID     SELECT          NULL
NULL     admin    system         public        eventlog    reportingID  SELECT          NULL
NULL     admin    system         public        eventlog    info         SELECT          NULL
NULL     admin    system         public        eventlog    uniqueID     SELECT          NULL
NULL     admin    system         public        eventlog    timestamp    INSERT          NULL
NULL     admin    system         public        eventlog    eventType    INSERT          NULL
NULL     admin    system         public        eventlog    targetID     INSERT          NULL
NULL     admin    system         public        eventlog    reportingID  INSERT          NULL
NULL     admin    system         public        eventlog    info         INSERT          NULL
NULL     admin    system         public        eventlog    uniqueID     INSERT          NULL
NULL     admin    system         public        eventlog    timestamp    UPDATE          NULL
NULL     admin    system         public        eventlog    eventType    UPDATE          NULL
NULL     admin    system         public        eventlog    targetID     UPDATE          NULL
NULL     admin    system         public        eventlog    reportingID  UPDATE          NULL
NULL     admin    system         public        eventlog    info         UPDATE          NULL
NULL     admin    system         public        eventlog    uniqueID     UPDATE          NULL
NULL     root     system         public        eventlog    timestamp    SELECT          NULL
NULL     root     system         public        eventlog    eventType    SELECT          NULL
NULL     root     system         public        eventlog    targetID     SELECT          NULL
NULL     root     system         public        eventlog    reportingID  SELECT          NULL
NULL     root     system         public        eventlog    info         SELECT          NULL
NULL     root     system         public        eventlog    uniqueID     SELECT          NULL
NULL     root     system         public        eventlog    timestamp    INSERT          NULL
NULL     root     system         public        eventlog    eventType    INSERT          NULL
NULL     root     system         public        eventlog    targetID     INSERT          NULL
NULL     root     system         public        eventlog    reportingID  INSERT          NULL
NULL     root     system         public        eventlog    info         INSERT          NULL
NULL     root     system         public        eventlog    uniqueID     INSERT          NULL
NULL     root     system         public        eventlog    timestamp    UPDATE          NULL
NULL     root     system         public        eventlog    eventType    UPDATE          NULL
NULL     root     system         public        eventlog    targetID     UPDATE          NULL
NULL     root     system         public        eventlog    reportingID  UPDATE          NULL
NULL     root     system         public        eventlog    info         UPDATE          NULL
NULL     root     system         public        eventlog    uniqueID     UPDATE          NULL

# information_schema.administrable_role_authorizations

query TTT colnames,rowsort
SELECT * FROM information_schema.administrable_role_authorizations
----
grantee  role_name  is_grantable
root     admin      YES

user testuser

query TTT colnames,rowsort
SELECT * FROM information_schema.administrable_role_authorizations
----
grantee  role_name  is_grantable

user root

# information_schema.applicable_roles

query TTT colnames,rowsort
SELECT * FROM information_schema.applicable_roles
----
grantee  role_name  is_grantable
root     admin      YES

user testuser

query TTT colnames,rowsort
SELECT * FROM information_schema.applicable_roles
----
grantee  role_name  is_grantable

user root

# information_schema.enabled_roles

query T colnames,rowsort
SELECT * FROM information_schema.enabled_roles
----
role_name
admin
root

user testuser

query T colnames,rowsort
SELECT * FROM information_schema.enabled_roles
----
role_name
testuser

user root

subtest fk_match_type

statement ok
CREATE DATABASE dfk; SET database=dfk

statement ok
CREATE TABLE v(x INT, y INT, UNIQUE (x,y))

statement ok
CREATE TABLE w(
  a INT, b INT, c INT, d INT,
  FOREIGN KEY (a,b) REFERENCES v(x,y) MATCH FULL,
  FOREIGN KEY (c,d) REFERENCES v(x,y) MATCH SIMPLE
  );

query TTTT rowsort
SELECT constraint_name, table_name, referenced_table_name, match_option
  FROM information_schema.referential_constraints
----
w_a_b_fkey  w  v  FULL
w_c_d_fkey  w  v  NONE

statement ok
SET database = test

statement ok
DROP DATABASE dfk CASCADE

# Regression test for #39787. Verify information_schema.ordinal_position
# matches pg_attribute.attnum when a leading column is dropped.

statement ok
CREATE TABLE ab(a INT, b INT)

statement ok
ALTER TABLE ab DROP COLUMN a

let $attnum
SELECT attnum FROM pg_attribute WHERE attrelid = 'ab'::regclass AND attname = 'b'

query I
SELECT
	ordinal_position
FROM
	information_schema.columns
WHERE
	table_name = 'ab'
	AND column_name = 'b'
	AND ordinal_position = $attnum;
----
2

statement ok
DROP TABLE ab

subtest column_udt_usage

statement ok
CREATE TYPE typ1 AS ENUM ('hello');
CREATE TYPE typ2 AS ENUM ('bye');
CREATE TABLE tb_enum_cols (x typ1, y INT, z typ2, w typ2)

query TTTTTT colnames,rowsort
SELECT * FROM information_schema.type_privileges WHERE type_name IN ('int', 'typ2')
----
grantee  type_catalog  type_schema  type_name  privilege_type  is_grantable
root     test          pg_catalog   int        ALL             NO
admin    test          pg_catalog   int        ALL             NO
public   test          pg_catalog   int        USAGE           NO
admin    test          public       typ2       ALL             YES
public   test          public       typ2       USAGE           NO
root     test          public       typ2       ALL             YES

statement ok
GRANT ALL ON TYPE typ2 TO testuser

query TTTTTT colnames,rowsort
SELECT * FROM information_schema.type_privileges WHERE type_name IN ('int', 'typ2')
----
grantee   type_catalog  type_schema  type_name  privilege_type  is_grantable
root      test          pg_catalog   int        ALL             NO
admin     test          pg_catalog   int        ALL             NO
public    test          pg_catalog   int        USAGE           NO
admin     test          public       typ2       ALL             YES
public    test          public       typ2       USAGE           NO
root      test          public       typ2       ALL             YES
testuser  test          public       typ2       ALL             NO

query TTTTTTT colnames,rowsort
SELECT * FROM information_schema.column_udt_usage
----
udt_catalog  udt_schema  udt_name  table_catalog  table_schema  table_name    column_name
test         public      typ1      test           public        tb_enum_cols  x
test         public      typ2      test           public        tb_enum_cols  z
test         public      typ2      test           public        tb_enum_cols  w

## information_schema.collations
subtest collations

query TTTT colnames
SELECT * FROM information_schema.collations ORDER BY collation_name
----
collation_catalog  collation_schema  collation_name       pad_attribute
test               pg_catalog        C                    NO PAD
test               pg_catalog        POSIX                NO PAD
test               pg_catalog        aa                   NO PAD
test               pg_catalog        af                   NO PAD
test               pg_catalog        ar                   NO PAD
test               pg_catalog        as                   NO PAD
test               pg_catalog        az                   NO PAD
test               pg_catalog        be                   NO PAD
test               pg_catalog        bg                   NO PAD
test               pg_catalog        bn                   NO PAD
test               pg_catalog        bs                   NO PAD
test               pg_catalog        bs-Cyrl              NO PAD
test               pg_catalog        ca                   NO PAD
test               pg_catalog        cs                   NO PAD
test               pg_catalog        cy                   NO PAD
test               pg_catalog        da                   NO PAD
test               pg_catalog        de                   NO PAD
test               pg_catalog        de-u-co-phonebk      NO PAD
test               pg_catalog        default              NO PAD
test               pg_catalog        dz                   NO PAD
test               pg_catalog        ee                   NO PAD
test               pg_catalog        el                   NO PAD
test               pg_catalog        en                   NO PAD
test               pg_catalog        en-US                NO PAD
test               pg_catalog        en-US-u-va-posix     NO PAD
test               pg_catalog        eo                   NO PAD
test               pg_catalog        es                   NO PAD
test               pg_catalog        et                   NO PAD
test               pg_catalog        fa                   NO PAD
test               pg_catalog        fa-AF                NO PAD
test               pg_catalog        fi                   NO PAD
test               pg_catalog        fi-u-co-standard     NO PAD
test               pg_catalog        fil                  NO PAD
test               pg_catalog        fo                   NO PAD
test               pg_catalog        fr                   NO PAD
test               pg_catalog        fr-CA                NO PAD
test               pg_catalog        gu                   NO PAD
test               pg_catalog        ha                   NO PAD
test               pg_catalog        haw                  NO PAD
test               pg_catalog        he                   NO PAD
test               pg_catalog        hi                   NO PAD
test               pg_catalog        hr                   NO PAD
test               pg_catalog        hu                   NO PAD
test               pg_catalog        hy                   NO PAD
test               pg_catalog        ig                   NO PAD
test               pg_catalog        is                   NO PAD
test               pg_catalog        ja                   NO PAD
test               pg_catalog        kk                   NO PAD
test               pg_catalog        kl                   NO PAD
test               pg_catalog        km                   NO PAD
test               pg_catalog        kn                   NO PAD
test               pg_catalog        ko                   NO PAD
test               pg_catalog        kok                  NO PAD
test               pg_catalog        ln                   NO PAD
test               pg_catalog        ln-u-co-phonetic     NO PAD
test               pg_catalog        lt                   NO PAD
test               pg_catalog        lv                   NO PAD
test               pg_catalog        mk                   NO PAD
test               pg_catalog        ml                   NO PAD
test               pg_catalog        mr                   NO PAD
test               pg_catalog        mt                   NO PAD
test               pg_catalog        my                   NO PAD
test               pg_catalog        nb                   NO PAD
test               pg_catalog        nn                   NO PAD
test               pg_catalog        nso                  NO PAD
test               pg_catalog        om                   NO PAD
test               pg_catalog        or                   NO PAD
test               pg_catalog        pa                   NO PAD
test               pg_catalog        pl                   NO PAD
test               pg_catalog        ps                   NO PAD
test               pg_catalog        ro                   NO PAD
test               pg_catalog        ru                   NO PAD
test               pg_catalog        se                   NO PAD
test               pg_catalog        si                   NO PAD
test               pg_catalog        sk                   NO PAD
test               pg_catalog        sl                   NO PAD
test               pg_catalog        sq                   NO PAD
test               pg_catalog        sr                   NO PAD
test               pg_catalog        sr-Latn              NO PAD
test               pg_catalog        ssy                  NO PAD
test               pg_catalog        sv                   NO PAD
test               pg_catalog        sv-u-co-standard     NO PAD
test               pg_catalog        ta                   NO PAD
test               pg_catalog        te                   NO PAD
test               pg_catalog        th                   NO PAD
test               pg_catalog        tn                   NO PAD
test               pg_catalog        to                   NO PAD
test               pg_catalog        tr                   NO PAD
test               pg_catalog        uk                   NO PAD
test               pg_catalog        und                  NO PAD
test               pg_catalog        ur                   NO PAD
test               pg_catalog        vi                   NO PAD
test               pg_catalog        wae                  NO PAD
test               pg_catalog        yo                   NO PAD
test               pg_catalog        zh                   NO PAD
test               pg_catalog        zh-Hant              NO PAD
test               pg_catalog        zh-Hant-u-co-pinyin  NO PAD
test               pg_catalog        zh-u-co-stroke       NO PAD


## information_schema.collation_character_set_applicability
subtest collation_character_set_applicability

query TTTTTT colnames,rowsort
SELECT * FROM information_schema.collation_character_set_applicability
----
collation_catalog  collation_schema  collation_name       character_set_catalog  character_set_schema  character_set_name
test               pg_catalog        default              NULL                   NULL                  UTF8
test               pg_catalog        C                    NULL                   NULL                  UTF8
test               pg_catalog        POSIX                NULL                   NULL                  UTF8
test               pg_catalog        und                  NULL                   NULL                  UTF8
test               pg_catalog        aa                   NULL                   NULL                  UTF8
test               pg_catalog        af                   NULL                   NULL                  UTF8
test               pg_catalog        ar                   NULL                   NULL                  UTF8
test               pg_catalog        as                   NULL                   NULL                  UTF8
test               pg_catalog        az                   NULL                   NULL                  UTF8
test               pg_catalog        be                   NULL                   NULL                  UTF8
test               pg_catalog        bg                   NULL                   NULL                  UTF8
test               pg_catalog        bn                   NULL                   NULL                  UTF8
test               pg_catalog        bs                   NULL                   NULL                  UTF8
test               pg_catalog        bs-Cyrl              NULL                   NULL                  UTF8
test               pg_catalog        ca                   NULL                   NULL                  UTF8
test               pg_catalog        cs                   NULL                   NULL                  UTF8
test               pg_catalog        cy                   NULL                   NULL                  UTF8
test               pg_catalog        da                   NULL                   NULL                  UTF8
test               pg_catalog        de-u-co-phonebk      NULL                   NULL                  UTF8
test               pg_catalog        de                   NULL                   NULL                  UTF8
test               pg_catalog        dz                   NULL                   NULL                  UTF8
test               pg_catalog        ee                   NULL                   NULL                  UTF8
test               pg_catalog        el                   NULL                   NULL                  UTF8
test               pg_catalog        en                   NULL                   NULL                  UTF8
test               pg_catalog        en-US                NULL                   NULL                  UTF8
test               pg_catalog        en-US-u-va-posix     NULL                   NULL                  UTF8
test               pg_catalog        eo                   NULL                   NULL                  UTF8
test               pg_catalog        es                   NULL                   NULL                  UTF8
test               pg_catalog        et                   NULL                   NULL                  UTF8
test               pg_catalog        fa                   NULL                   NULL                  UTF8
test               pg_catalog        fa-AF                NULL                   NULL                  UTF8
test               pg_catalog        fi                   NULL                   NULL                  UTF8
test               pg_catalog        fi-u-co-standard     NULL                   NULL                  UTF8
test               pg_catalog        fil                  NULL                   NULL                  UTF8
test               pg_catalog        fo                   NULL                   NULL                  UTF8
test               pg_catalog        fr                   NULL                   NULL                  UTF8
test               pg_catalog        fr-CA                NULL                   NULL                  UTF8
test               pg_catalog        gu                   NULL                   NULL                  UTF8
test               pg_catalog        ha                   NULL                   NULL                  UTF8
test               pg_catalog        haw                  NULL                   NULL                  UTF8
test               pg_catalog        he                   NULL                   NULL                  UTF8
test               pg_catalog        hi                   NULL                   NULL                  UTF8
test               pg_catalog        hr                   NULL                   NULL                  UTF8
test               pg_catalog        hu                   NULL                   NULL                  UTF8
test               pg_catalog        hy                   NULL                   NULL                  UTF8
test               pg_catalog        ig                   NULL                   NULL                  UTF8
test               pg_catalog        is                   NULL                   NULL                  UTF8
test               pg_catalog        ja                   NULL                   NULL                  UTF8
test               pg_catalog        kk                   NULL                   NULL                  UTF8
test               pg_catalog        kl                   NULL                   NULL                  UTF8
test               pg_catalog        km                   NULL                   NULL                  UTF8
test               pg_catalog        kn                   NULL                   NULL                  UTF8
test               pg_catalog        ko                   NULL                   NULL                  UTF8
test               pg_catalog        kok                  NULL                   NULL                  UTF8
test               pg_catalog        ln-u-co-phonetic     NULL                   NULL                  UTF8
test               pg_catalog        ln                   NULL                   NULL                  UTF8
test               pg_catalog        lt                   NULL                   NULL                  UTF8
test               pg_catalog        lv                   NULL                   NULL                  UTF8
test               pg_catalog        mk                   NULL                   NULL                  UTF8
test               pg_catalog        ml                   NULL                   NULL                  UTF8
test               pg_catalog        mr                   NULL                   NULL                  UTF8
test               pg_catalog        mt                   NULL                   NULL                  UTF8
test               pg_catalog        my                   NULL                   NULL                  UTF8
test               pg_catalog        nb                   NULL                   NULL                  UTF8
test               pg_catalog        nn                   NULL                   NULL                  UTF8
test               pg_catalog        nso                  NULL                   NULL                  UTF8
test               pg_catalog        om                   NULL                   NULL                  UTF8
test               pg_catalog        or                   NULL                   NULL                  UTF8
test               pg_catalog        pa                   NULL                   NULL                  UTF8
test               pg_catalog        pl                   NULL                   NULL                  UTF8
test               pg_catalog        ps                   NULL                   NULL                  UTF8
test               pg_catalog        ro                   NULL                   NULL                  UTF8
test               pg_catalog        ru                   NULL                   NULL                  UTF8
test               pg_catalog        se                   NULL                   NULL                  UTF8
test               pg_catalog        si                   NULL                   NULL                  UTF8
test               pg_catalog        sk                   NULL                   NULL                  UTF8
test               pg_catalog        sl                   NULL                   NULL                  UTF8
test               pg_catalog        sq                   NULL                   NULL                  UTF8
test               pg_catalog        sr                   NULL                   NULL                  UTF8
test               pg_catalog        sr-Latn              NULL                   NULL                  UTF8
test               pg_catalog        ssy                  NULL                   NULL                  UTF8
test               pg_catalog        sv                   NULL                   NULL                  UTF8
test               pg_catalog        sv-u-co-standard     NULL                   NULL                  UTF8
test               pg_catalog        ta                   NULL                   NULL                  UTF8
test               pg_catalog        te                   NULL                   NULL                  UTF8
test               pg_catalog        th                   NULL                   NULL                  UTF8
test               pg_catalog        tn                   NULL                   NULL                  UTF8
test               pg_catalog        to                   NULL                   NULL                  UTF8
test               pg_catalog        tr                   NULL                   NULL                  UTF8
test               pg_catalog        uk                   NULL                   NULL                  UTF8
test               pg_catalog        ur                   NULL                   NULL                  UTF8
test               pg_catalog        vi                   NULL                   NULL                  UTF8
test               pg_catalog        wae                  NULL                   NULL                  UTF8
test               pg_catalog        yo                   NULL                   NULL                  UTF8
test               pg_catalog        zh                   NULL                   NULL                  UTF8
test               pg_catalog        zh-u-co-stroke       NULL                   NULL                  UTF8
test               pg_catalog        zh-Hant-u-co-pinyin  NULL                   NULL                  UTF8
test               pg_catalog        zh-Hant              NULL                   NULL                  UTF8


## information_schema.session_variables
subtest variables

## Excluding crdb_version and session_id variables as they are generated on each
## commit/session.; , experimental_distsql_planning and vectorize as they
## depend on distsql and vectorization turned on/off. Also excluding distsql,
## vectorize, experimental_distsql_planning, use_declarative_schema_changer,
## autocommit_before_ddl, default_transaction_isolation, and distsql_workmem
## which can be adjusted based on the logic test mode.
query TT colnames
SELECT
  *
FROM
  information_schema.session_variables
WHERE
  variable
  NOT IN (
      'crdb_version',
      'session_id',
      'distsql',
      'vectorize',
      'experimental_distsql_planning',
      'use_declarative_schema_changer',
      'distsql_workmem',
      'copy_fast_path_enabled',
      'direct_columnar_scans_enabled',
      'multiple_active_portals_enabled',
      'autocommit_before_ddl',
      'default_transaction_isolation',
      'transaction_isolation'
    )
ORDER BY variable
----
variable                                                   value
allow_ordinal_column_references                            off
allow_role_memberships_to_change_during_transaction        off
alter_primary_region_super_region_override                 off
always_distribute_full_scans                               off
application_name                                           ·
authentication_method                                      cert-password
avoid_buffering                                            off
avoid_full_table_scans_in_mutations                        on
backslash_quote                                            safe_encoding
bypass_pcr_reader_catalog_aost                             off
bytea_output                                               hex
check_function_bodies                                      on
client_encoding                                            UTF8
client_min_messages                                        notice
close_cursors_at_commit                                    on
copy_from_atomic_enabled                                   on
copy_from_retries_enabled                                  on
copy_num_retries_per_batch                                 5
copy_transaction_quality_of_service                        background
copy_write_pipelining_enabled                              off
cost_scans_with_default_col_size                           off
database                                                   test
datestyle                                                  ISO, MDY
deadlock_timeout                                           0
declare_cursor_statement_timeout_enabled                   on
default_int_size                                           8
default_table_access_method                                heap
default_tablespace                                         ·
default_text_search_config                                 pg_catalog.english
default_transaction_priority                               normal
default_transaction_quality_of_service                     regular
default_transaction_read_only                              off
default_transaction_use_follower_reads                     off
default_with_oids                                          off
descriptor_validation                                      on
disable_changefeed_replication                             off
disable_hoist_projection_in_join_limitation                off
disable_partially_distributed_plans                        off
disable_plan_gists                                         off
disable_vec_union_eager_cancellation                       off
disallow_full_table_scans                                  off
distribute_group_by_row_count_threshold                    1000
distribute_join_row_count_threshold                        1000
distribute_scan_row_count_threshold                        10000
distribute_sort_row_count_threshold                        1000
distsql_plan_gateway_bias                                  2
enable_auto_rehoming                                       off
enable_create_stats_using_extremes                         on
enable_create_stats_using_extremes_bool_enum               off
enable_durable_locking_for_serializable                    off
enable_experimental_alter_column_type_general              off
enable_implicit_fk_locking_for_serializable                off
enable_implicit_select_for_update                          on
enable_implicit_transaction_for_batch_statements           on
enable_insert_fast_path                                    on
enable_multiple_modifications_of_table                     off
enable_multiregion_placement_policy                        off
enable_seqscan                                             on
enable_shared_locking_for_serializable                     off
enable_super_regions                                       off
enable_zigzag_join                                         off
enforce_home_region                                        off
enforce_home_region_follower_reads_enabled                 off
escape_string_warning                                      on
expect_and_ignore_not_visible_columns_in_copy              off
experimental_enable_implicit_column_partitioning           off
experimental_enable_temp_tables                            off
experimental_enable_unique_without_index_constraints       on
experimental_hash_group_join_enabled                       off
extra_float_digits                                         1
force_savepoint_restart                                    off
foreign_key_cascades_limit                                 10000
idle_in_transaction_session_timeout                        0
idle_session_timeout                                       0
index_join_streamer_batch_size                             8.0 MiB
index_recommendations_enabled                              off
inject_retry_errors_enabled                                off
inject_retry_errors_on_commit_enabled                      off
integer_datetimes                                          on
intervalstyle                                              postgres
is_superuser                                               on
join_reader_index_join_strategy_batch_size                 4.0 MiB
join_reader_no_ordering_strategy_batch_size                2.0 MiB
join_reader_ordering_strategy_batch_size                   100 KiB
large_full_scan_rows                                       0
lc_collate                                                 C.UTF-8
lc_ctype                                                   C.UTF-8
lc_messages                                                C.UTF-8
lc_monetary                                                C.UTF-8
lc_numeric                                                 C.UTF-8
lc_time                                                    C.UTF-8
legacy_varchar_typing                                      off
locality                                                   region=test,dc=dc1
locality_optimized_partitioned_index_scan                  on
lock_timeout                                               0
log_timezone                                               UTC
max_connections                                            -1
max_identifier_length                                      128
max_index_keys                                             32
max_prepared_transactions                                  2147483647
max_retries_for_read_committed                             10
node_id                                                    1
null_ordered_last                                          off
on_update_rehome_row_enabled                               on
opt_split_scan_limit                                       2048
optimizer                                                  on
optimizer_always_use_histograms                            on
optimizer_hoist_uncorrelated_equality_subqueries           on
optimizer_merge_joins_enabled                              on
optimizer_prove_implication_with_virtual_computed_columns  on
optimizer_push_limit_into_project_filtered_scan            on
optimizer_push_offset_into_index_join                      on
optimizer_use_conditional_hoist_fix                        on
optimizer_use_forecasts                                    on
optimizer_use_histograms                                   on
optimizer_use_improved_computed_column_filters_derivation  on
optimizer_use_improved_disjunction_stats                   on
optimizer_use_improved_distinct_on_limit_hint_costing      on
optimizer_use_improved_join_elimination                    on
optimizer_use_improved_multi_column_selectivity_estimate   on
optimizer_use_improved_split_disjunction_for_joins         on
optimizer_use_improved_trigram_similarity_selectivity      on
optimizer_use_improved_zigzag_join_costing                 on
optimizer_use_limit_ordering_for_streaming_group_by        on
optimizer_use_lock_op_for_serializable                     off
optimizer_use_merged_partial_statistics                    off
optimizer_use_multicol_stats                               on
optimizer_use_not_visible_indexes                          off
optimizer_use_polymorphic_parameter_fix                    on
optimizer_use_provided_ordering_fix                        on
optimizer_use_trigram_similarity_optimization              on
optimizer_use_virtual_computed_column_stats                on
override_multi_region_zone_config                          off
parallelize_multi_key_lookup_joins_enabled                 off
password_encryption                                        scram-sha-256
pg_trgm.similarity_threshold                               0.3
plan_cache_mode                                            auto
plpgsql_use_strict_into                                    off
prefer_lookup_joins_for_fks                                off
prepared_statements_cache_size                             0 B
propagate_input_ordering                                   off
recursion_depth_limit                                      1000
reorder_joins_limit                                        8
require_explicit_primary_keys                              off
results_buffer_size                                        524288
role                                                       none
row_security                                               off
search_path                                                "$user", public
serial_normalization                                       rowid
server_encoding                                            UTF8
server_version                                             13.0.0
server_version_num                                         130000
show_primary_key_constraint_on_not_visible_columns         on
sql_safe_updates                                           off
ssl                                                        on
standard_conforming_strings                                on
statement_timeout                                          0
streamer_always_maintain_ordering                          off
streamer_enabled                                           on
streamer_head_of_line_only_fraction                        0.8
streamer_in_order_eager_memory_usage_fraction              0.5
streamer_out_of_order_eager_memory_usage_fraction          0.8
strict_ddl_atomicity                                       off
stub_catalog_tables                                        on
synchronize_seqscans                                       on
synchronous_commit                                         on
system_identity                                            root
testing_optimizer_cost_perturbation                        0
testing_optimizer_disable_rule_probability                 0
testing_optimizer_inject_panics                            off
testing_optimizer_random_seed                              0
testing_vectorize_inject_panics                            off
timezone                                                   UTC
tracing                                                    off
transaction_priority                                       normal
transaction_read_only                                      off
transaction_rows_read_err                                  0
transaction_rows_read_log                                  0
transaction_rows_written_err                               0
transaction_rows_written_log                               0
transaction_status                                         NoTxn
transaction_timeout                                        0
troubleshooting_mode                                       off
unbounded_parallel_scans                                   off
unconstrained_non_covering_index_scan_enabled              off
unsafe_allow_triggers_modifying_cascades                   off
variable_inequality_lookup_join_enabled                    on
xmloption                                                  content

# information_schema can be used with the anonymous database.
# It should show information across all databases.
subtest anonymous_database

statement ok
CREATE TABLE t1(a INT PRIMARY KEY, b BOOLEAN);
CREATE DATABASE other_db;
SET DATABASE = other_db;
CREATE TABLE t2(c STRING PRIMARY KEY, d DECIMAL);

query TTTTI colnames
SELECT table_catalog, table_schema, table_name, column_name, ordinal_position
FROM "".information_schema.columns
WHERE (table_catalog = 'test' OR table_catalog = 'other_db')
AND table_schema = 'public'
AND (table_name = 't1' OR table_name = 't2')
ORDER BY 3,4
----
table_catalog  table_schema  table_name  column_name  ordinal_position
test           public        t1          a            1
test           public        t1          b            2
test           public        t2          a            1
other_db       public        t2          c            1
other_db       public        t2          d            2
test           public        t2          rowid        2

statement ok
SET DATABASE = "";

query TTTTI colnames
SELECT table_catalog, table_schema, table_name, column_name, ordinal_position
FROM "".information_schema.columns
WHERE (table_catalog = 'test' OR table_catalog = 'other_db')
AND table_schema = 'public'
AND (table_name = 't1' OR table_name = 't2')
ORDER BY 3,4
----
table_catalog  table_schema  table_name  column_name  ordinal_position
test           public        t1          a            1
test           public        t1          b            2
test           public        t2          a            1
other_db       public        t2          c            1
other_db       public        t2          d            2
test           public        t2          rowid        2

statement ok
SET DATABASE = test

# Testing udt_type at information_schema.columns and data_type
statement ok
CREATE DATABASE enum_db;
SET DATABASE = enum_db;
CREATE SCHEMA sh;
CREATE TYPE e AS ENUM ('a', 'b');
CREATE TYPE sh.d AS ENUM('x', 'y');
CREATE TABLE t (e e, d sh.d, a e[]);

query TTT colnames
select udt_schema, udt_name, data_type
from information_schema.columns
where table_name = 't'
ORDER BY udt_name
----
udt_schema  udt_name  data_type
public      _e        ARRAY
sh          d         USER-DEFINED
public      e         USER-DEFINED
pg_catalog  int8      bigint

# Testing information_schema.columns.is_identity which for now is False for every column
statement ok
SET DATABASE = "";

query T colnames,rowsort
SELECT distinct is_identity FROM information_schema.columns
----
is_identity
NO
YES

statement ok
SET DATABASE = test

# Regression test for #70505. Inaccessible columns should not be included in
# information_schema.columns.
subtest regression_70505

statement ok
CREATE TABLE t70505 (k INT PRIMARY KEY, a INT, b INT, INDEX ((a + b), (a + 10)))

query T rowsort
SELECT column_name FROM information_schema.columns WHERE table_name = 't70505'
----
k
a
b


subtest identity_columns

statement ok
CREATE TABLE t (
  id1 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 10),
  id2 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START 10),
  id3 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE 5),
  id4 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT 5),
  id5 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START 2 INCREMENT 5),
  id6 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT BY -1 START -5),
  id7 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE 5 MAXVALUE 10),
  id8 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MAXVALUE 10 START WITH 9),
  id9 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT BY -1 MINVALUE -10 START WITH -10),
  id10 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 9223372036854775807),
  id11 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE -9223372036854775808 START WITH -9223372036854775808 INCREMENT -1),
  id12 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (VIRTUAL),
  id13 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (CACHE 10 INCREMENT 1),
  id14 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT 5),
  id15 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MAXVALUE 4 START WITH 2 CACHE 5 INCREMENT BY 2),
  id16 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE -4 START WITH -2 CACHE 5 INCREMENT BY -2),
  id17 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE -2 MAXVALUE 2 START WITH 2 CACHE 5 INCREMENT BY -2),
  id18 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS int2 START WITH -4 INCREMENT BY -3),
  id19 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS integer),
  id20 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS int8),
  id21 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS smallint),
  id22 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS integer START WITH 2 INCREMENT BY 1 MINVALUE 0 MAXVALUE 234567 CACHE 1),
  id23 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS smallint START WITH -4 INCREMENT BY -3),
  id24 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (AS integer START WITH 1 INCREMENT BY 1 MAXVALUE 9001 CACHE 1),
  id25 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT  BY 3  MINVALUE 6 MAXVALUE 10),
  id26 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (MINVALUE -2 MAXVALUE 2 START WITH 1 CACHE 5 INCREMENT BY -2),
  id27 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY (INCREMENT  BY 3  MINVALUE 6 MAXVALUE 12),
  id28 INT8 NOT NULL GENERATED BY DEFAULT AS IDENTITY
)

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id1';
----
10  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id2';
----
10  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id3';
----
5  1  9223372036854775807  5  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id4';
----
1  5  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id5';
----
2  5  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id6';
----
-5  -1  -1  -9223372036854775808  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id7';
----
5  1  10  5  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id8';
----
9  1  10  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id9';
----
-10  -1  -1  -10  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id10';
----
9223372036854775807  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id11';
----
-9223372036854775808  -1  -1  -9223372036854775808  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id12';
----
1  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id13';
----
1  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id14';
----
1  5  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id15';
----
2  2  4  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id16';
----
-2  -2  -1  -4  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id17';
----
2  -2  2  -2  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id18';
----
-4  -3  -1  -32768  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id19';
----
1  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id20';
----
1  1  9223372036854775807  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id21';
----
1  1  32767  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id22';
----
2  1  234567  0  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id23';
----
-4  -3  -1  -32768  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id24';
----
1  1  9001  1  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id25';
----
6  3  10  6  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id26';
----
1  -2  2  -2  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id27';
----
6  3  12  6  NULL

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id28';
----
1  1  9223372036854775807  1  NULL


subtest get_seq_opt_with_default_int_size

statement ok
DROP TABLE IF EXISTS t

statement ok
SET default_int_size=4

statement ok
CREATE TABLE t (
  id1 INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10)
)

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id1';
----
10  1  2147483647  1  NULL

statement ok
DROP TABLE IF EXISTS t

statement ok
SET default_int_size=8

statement ok
CREATE TABLE t (
  id1 INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10)
)

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id1';
----
10  1  9223372036854775807  1  NULL

statement ok
DROP TABLE IF EXISTS t

statement ok
set default_int_size = 8;

statement ok
CREATE TABLE t (
  id1 INT GENERATED BY DEFAULT AS IDENTITY (START WITH 10)
)

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id1';
----
10  1  9223372036854775807  1  NULL

statement ok
set default_int_size = 4;

query TTTTT
select identity_start, identity_increment, identity_maximum, identity_minimum, identity_cycle from information_schema.columns where table_name = 't' and column_name='id1';
----
10  1  9223372036854775807  1  NULL

subtest generated_as_cols

statement ok
DROP TABLE IF EXISTS t

statement ok
CREATE TABLE t (i INTEGER PRIMARY KEY, x VARCHAR, y VARCHAR, z VARCHAR GENERATED ALWAYS AS (x || ' ' || y) STORED);

query TT rowsort
SELECT column_name, is_generated FROM information_schema.columns WHERE table_name = 't';
----
i  NEVER
x  NEVER
y  NEVER
z  ALWAYS

subtest role_routine_grants

query TTTTTTTTTT colnames
SELECT * FROM information_schema.role_routine_grants
WHERE reverse(split_part(reverse(specific_name), '_', 1))::INT < 50
ORDER BY specific_name, grantee;
----
grantor  grantee  specific_catalog  specific_schema  specific_name  routine_catalog  routine_schema  routine_name  privilege_type  is_grantable
NULL     admin    test              pg_catalog       array_agg_1    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_1    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_1    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_10   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_10   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_10   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_11   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_11   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_11   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_12   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_12   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_12   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_13   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_13   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_13   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_14   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_14   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_14   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_15   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_15   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_15   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_16   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_16   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_16   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_17   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_17   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_17   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_18   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_18   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_18   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_19   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_19   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_19   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_2    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_2    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_2    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_20   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_20   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_20   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_21   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_21   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_21   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_22   test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_22   test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_22   test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_3    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_3    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_3    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_4    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_4    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_4    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_5    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_5    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_5    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_6    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_6    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_6    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_7    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_7    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_7    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_8    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_8    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_8    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       array_agg_9    test             pg_catalog      array_agg     EXECUTE         NO
NULL     public   test              pg_catalog       array_agg_9    test             pg_catalog      array_agg     EXECUTE         NO
NULL     root     test              pg_catalog       array_agg_9    test             pg_catalog      array_agg     EXECUTE         NO
NULL     admin    test              pg_catalog       avg_23         test             pg_catalog      avg           EXECUTE         NO
NULL     public   test              pg_catalog       avg_23         test             pg_catalog      avg           EXECUTE         NO
NULL     root     test              pg_catalog       avg_23         test             pg_catalog      avg           EXECUTE         NO
NULL     admin    test              pg_catalog       avg_24         test             pg_catalog      avg           EXECUTE         NO
NULL     public   test              pg_catalog       avg_24         test             pg_catalog      avg           EXECUTE         NO
NULL     root     test              pg_catalog       avg_24         test             pg_catalog      avg           EXECUTE         NO
NULL     admin    test              pg_catalog       avg_25         test             pg_catalog      avg           EXECUTE         NO
NULL     public   test              pg_catalog       avg_25         test             pg_catalog      avg           EXECUTE         NO
NULL     root     test              pg_catalog       avg_25         test             pg_catalog      avg           EXECUTE         NO
NULL     admin    test              pg_catalog       avg_26         test             pg_catalog      avg           EXECUTE         NO
NULL     public   test              pg_catalog       avg_26         test             pg_catalog      avg           EXECUTE         NO
NULL     root     test              pg_catalog       avg_26         test             pg_catalog      avg           EXECUTE         NO
NULL     admin    test              pg_catalog       bit_and_27     test             pg_catalog      bit_and       EXECUTE         NO
NULL     public   test              pg_catalog       bit_and_27     test             pg_catalog      bit_and       EXECUTE         NO
NULL     root     test              pg_catalog       bit_and_27     test             pg_catalog      bit_and       EXECUTE         NO
NULL     admin    test              pg_catalog       bit_and_28     test             pg_catalog      bit_and       EXECUTE         NO
NULL     public   test              pg_catalog       bit_and_28     test             pg_catalog      bit_and       EXECUTE         NO
NULL     root     test              pg_catalog       bit_and_28     test             pg_catalog      bit_and       EXECUTE         NO
NULL     admin    test              pg_catalog       bit_or_29      test             pg_catalog      bit_or        EXECUTE         NO
NULL     public   test              pg_catalog       bit_or_29      test             pg_catalog      bit_or        EXECUTE         NO
NULL     root     test              pg_catalog       bit_or_29      test             pg_catalog      bit_or        EXECUTE         NO
NULL     admin    test              pg_catalog       bit_or_30      test             pg_catalog      bit_or        EXECUTE         NO
NULL     public   test              pg_catalog       bit_or_30      test             pg_catalog      bit_or        EXECUTE         NO
NULL     root     test              pg_catalog       bit_or_30      test             pg_catalog      bit_or        EXECUTE         NO
NULL     admin    test              pg_catalog       bool_and_31    test             pg_catalog      bool_and      EXECUTE         NO
NULL     public   test              pg_catalog       bool_and_31    test             pg_catalog      bool_and      EXECUTE         NO
NULL     root     test              pg_catalog       bool_and_31    test             pg_catalog      bool_and      EXECUTE         NO
NULL     admin    test              pg_catalog       bool_or_32     test             pg_catalog      bool_or       EXECUTE         NO
NULL     public   test              pg_catalog       bool_or_32     test             pg_catalog      bool_or       EXECUTE         NO
NULL     root     test              pg_catalog       bool_or_32     test             pg_catalog      bool_or       EXECUTE         NO
NULL     admin    test              pg_catalog       concat_agg_33  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     public   test              pg_catalog       concat_agg_33  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     root     test              pg_catalog       concat_agg_33  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     admin    test              pg_catalog       concat_agg_34  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     public   test              pg_catalog       concat_agg_34  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     root     test              pg_catalog       concat_agg_34  test             pg_catalog      concat_agg    EXECUTE         NO
NULL     admin    test              pg_catalog       corr_35        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_35        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_35        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_36        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_36        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_36        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_37        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_37        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_37        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_38        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_38        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_38        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_39        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_39        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_39        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_40        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_40        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_40        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_41        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_41        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_41        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_42        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_42        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_42        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       corr_43        test             pg_catalog      corr          EXECUTE         NO
NULL     public   test              pg_catalog       corr_43        test             pg_catalog      corr          EXECUTE         NO
NULL     root     test              pg_catalog       corr_43        test             pg_catalog      corr          EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_44   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_44   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_44   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_45   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_45   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_45   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_46   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_46   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_46   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_47   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_47   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_47   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_48   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_48   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_48   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     admin    test              pg_catalog       covar_pop_49   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     public   test              pg_catalog       covar_pop_49   test             pg_catalog      covar_pop     EXECUTE         NO
NULL     root     test              pg_catalog       covar_pop_49   test             pg_catalog      covar_pop     EXECUTE         NO

subtest end

subtest user_defined_types

statement ok
CREATE TYPE u AS (ufoo int, ubar int);

query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.user_defined_types
----
column_name                 data_type  is_nullable  column_default  generation_expression  indices  is_hidden
user_defined_type_catalog   STRING     true         NULL            ·                      {}       false
user_defined_type_schema    STRING     true         NULL            ·                      {}       false
user_defined_type_name      STRING     true         NULL            ·                      {}       false
user_defined_type_category  STRING     true         NULL            ·                      {}       false
is_instantiable             STRING     true         NULL            ·                      {}       false
is_final                    STRING     true         NULL            ·                      {}       false
ordering_form               STRING     true         NULL            ·                      {}       false
ordering_category           STRING     true         NULL            ·                      {}       false
ordering_routine_catalog    STRING     true         NULL            ·                      {}       false
ordering_routine_schema     STRING     true         NULL            ·                      {}       false
ordering_routine_name       STRING     true         NULL            ·                      {}       false
reference_type              STRING     true         NULL            ·                      {}       false
data_type                   STRING     true         NULL            ·                      {}       false
character_maximum_length    INT8       true         NULL            ·                      {}       false
character_octet_length      INT8       true         NULL            ·                      {}       false
character_set_catalog       STRING     true         NULL            ·                      {}       false
character_set_schema        STRING     true         NULL            ·                      {}       false
character_set_name          STRING     true         NULL            ·                      {}       false
collation_catalog           STRING     true         NULL            ·                      {}       false
collation_schema            STRING     true         NULL            ·                      {}       false
collation_name              STRING     true         NULL            ·                      {}       false
numeric_precision           INT8       true         NULL            ·                      {}       false
numeric_precision_radix     INT8       true         NULL            ·                      {}       false
numeric_scale               INT8       true         NULL            ·                      {}       false
datetime_precision          INT8       true         NULL            ·                      {}       false
interval_type               STRING     true         NULL            ·                      {}       false
interval_precision          INT8       true         NULL            ·                      {}       false
source_dtd_identifier       STRING     true         NULL            ·                      {}       false
ref_dtd_identifier          STRING     true         NULL            ·                      {}       false

query TTTTTTTTTTTTTIITTTTTTIIIITITT colnames,rowsort
SELECT * FROM information_schema.user_defined_types WHERE user_defined_type_name = 'u'
----
user_defined_type_catalog  user_defined_type_schema  user_defined_type_name  user_defined_type_category  is_instantiable  is_final  ordering_form  ordering_category  ordering_routine_catalog  ordering_routine_schema  ordering_routine_name  reference_type  data_type  character_maximum_length  character_octet_length  character_set_catalog  character_set_schema  character_set_name  collation_catalog  collation_schema  collation_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision  interval_type  interval_precision  source_dtd_identifier  ref_dtd_identifier
test                       public                    u                       STRUCTURED                  YES              NULL      NULL           NULL               NULL                      NULL                     NULL                   NULL            NULL       NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            NULL               NULL                     NULL           NULL                NULL           NULL                NULL                   NULL

query TTTTTTTTTTTTTIITTTTTTIIIITITT colnames,rowsort
SELECT * FROM information_schema.user_defined_types WHERE user_defined_type_name = 'dne'
----
user_defined_type_catalog  user_defined_type_schema  user_defined_type_name  user_defined_type_category  is_instantiable  is_final  ordering_form  ordering_category  ordering_routine_catalog  ordering_routine_schema  ordering_routine_name  reference_type  data_type  character_maximum_length  character_octet_length  character_set_catalog  character_set_schema  character_set_name  collation_catalog  collation_schema  collation_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision  interval_type  interval_precision  source_dtd_identifier  ref_dtd_identifier

subtest end

subtest attributes

query TTBTTTB colnames,rowsort
SHOW COLUMNS FROM information_schema.attributes
----
column_name                     data_type  is_nullable  column_default  generation_expression  indices  is_hidden
udt_catalog                     STRING     true         NULL            ·                      {}       false
udt_schema                      STRING     true         NULL            ·                      {}       false
udt_name                        STRING     true         NULL            ·                      {}       false
attribute_name                  STRING     true         NULL            ·                      {}       false
ordinal_position                INT8       true         NULL            ·                      {}       false
attribute_default               STRING     true         NULL            ·                      {}       false
is_nullable                     STRING     true         NULL            ·                      {}       false
data_type                       STRING     true         NULL            ·                      {}       false
character_maximum_length        INT8       true         NULL            ·                      {}       false
character_octet_length          INT8       true         NULL            ·                      {}       false
character_set_catalog           STRING     true         NULL            ·                      {}       false
character_set_schema            STRING     true         NULL            ·                      {}       false
character_set_name              STRING     true         NULL            ·                      {}       false
collation_catalog               STRING     true         NULL            ·                      {}       false
collation_schema                STRING     true         NULL            ·                      {}       false
collation_name                  STRING     true         NULL            ·                      {}       false
numeric_precision               INT8       true         NULL            ·                      {}       false
numeric_precision_radix         INT8       true         NULL            ·                      {}       false
numeric_scale                   INT8       true         NULL            ·                      {}       false
datetime_precision              INT8       true         NULL            ·                      {}       false
interval_type                   STRING     true         NULL            ·                      {}       false
interval_precision              INT8       true         NULL            ·                      {}       false
attribute_udt_catalog           STRING     true         NULL            ·                      {}       false
attribute_udt_schema            STRING     true         NULL            ·                      {}       false
attribute_udt_name              STRING     true         NULL            ·                      {}       false
scope_catalog                   STRING     true         NULL            ·                      {}       false
scope_schema                    STRING     true         NULL            ·                      {}       false
scope_name                      STRING     true         NULL            ·                      {}       false
maximum_cardinality             INT8       true         NULL            ·                      {}       false
dtd_identifier                  STRING     true         NULL            ·                      {}       false
is_derived_reference_attribute  STRING     true         NULL            ·                      {}       false

query TTTTITTTIITTTTTTIIIITITTTTTTITT colnames,rowsort
SELECT * FROM information_schema.attributes WHERE udt_name = 'u'
----
udt_catalog  udt_schema  udt_name  attribute_name  ordinal_position  attribute_default  is_nullable  data_type  character_maximum_length  character_octet_length  character_set_catalog  character_set_schema  character_set_name  collation_catalog  collation_schema  collation_name  numeric_precision  numeric_precision_radix  numeric_scale  datetime_precision  interval_type  interval_precision  attribute_udt_catalog  attribute_udt_schema  attribute_udt_name  scope_catalog  scope_schema  scope_name  maximum_cardinality  dtd_identifier  is_derived_reference_attribute
test         public      u         ufoo            1                 NULL               YES          integer    NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            32                 2                        0              NULL                NULL           NULL                test                   pg_catalog            int4                NULL           NULL          NULL        NULL                 1               NO
test         public      u         ubar            2                 NULL               YES          integer    NULL                      NULL                    NULL                   NULL                  NULL                NULL               NULL              NULL            32                 2                        0              NULL                NULL           NULL                test                   pg_catalog            int4                NULL           NULL          NULL        NULL                 2               NO

subtest end
