RefLib

Reference library for AI

Back

postgresql_16:3.6.26.3 Schema Visibility Inquiry Functions

PostgreSQL 16 > The SQL Language > Functions and Operators > System Information Functions and Operators > Schema Visibility Inquiry Functions

(see functions-info-schema-table) shows functions that determine whether a certain object is *visible* in the current schema search path. For example, a table is said to be visible if its containing schema is in the search path and no table of the same name appears earlier in the search path. This is equivalent to the statement that the table can be referenced by name without explicit schema qualification. Thus, to list the names of all visible tables: SELECT relname FROM pg_class WHERE pg_table_is_visible(oid); For functions and operators, an object in the search path is said to be visible if there is no object of the same name *and argument data type(s)* earlier in the path. For operator classes and families, both the name and the associated index access method are considered.

| Function Description | | --- | | pg_collation_is_visible ( collation oid ) boolean Is collation visible in search path? | | pg_conversion_is_visible ( conversion oid ) boolean Is conversion visible in search path? | | pg_function_is_visible ( function oid ) boolean Is function visible in search path? (This also works for procedures and aggregates.) | | pg_opclass_is_visible ( opclass oid ) boolean Is operator class visible in search path? | | pg_operator_is_visible ( operator oid ) boolean Is operator visible in search path? | | pg_opfamily_is_visible ( opclass oid ) boolean Is operator family visible in search path? | | pg_statistics_obj_is_visible ( stat oid ) boolean Is statistics object visible in search path? | | pg_table_is_visible ( table oid ) boolean Is table visible in search path? (This works for all types of relations, including views, materialized views, indexes, sequences and foreign tables.) | | pg_ts_config_is_visible ( config oid ) boolean Is text search configuration visible in search path? | | pg_ts_dict_is_visible ( dict oid ) boolean Is text search dictionary visible in search path? | | pg_ts_parser_is_visible ( parser oid ) boolean Is text search parser visible in search path? | | pg_ts_template_is_visible ( template oid ) boolean Is text search template visible in search path? | | pg_type_is_visible ( type oid ) boolean Is type (or domain) visible in search path? |

All these functions require object OIDs to identify the object to be checked. If you want to test an object by name, it is convenient to use the OID alias types (regclass, regtype, regprocedure, regoperator, regconfig, or regdictionary), for example: SELECT pg_type_is_visible('myschema.widget'::regtype); Note that it would not make much sense to test a non-schema-qualified type name in this way — if the name can be recognized at all, it must be visible.

Back