pg_type_is_visible()

用于确定数据类型在当前搜索路径中是否可见的函数

pg_type_is_visible() 是一个系统函数,用于确定数据类型或 是否在当前模式搜索路径中可见。

pg_type_is_visible() 函数于 PostgreSQL 7.3 中添加。

用法

pg_type_is_visible ( type oid ) → boolean

可以通过包含类型名称的 regtype OID 别名,以文本值的形式提供 type 参数。在这种情况下,类型名称应以模式限定的形式提供(例如,“someschema.sometype”),否则,如果类型存在但不在当前搜索路径中可见,则会引发 ERROR

变更历史

示例

假设 hstore 扩展已安装到 hstore 模式中,pg_type_is_visible() 的示例用法。

postgres=# \dT hstore.*
       List of data types
 Schema |  Name   | Description 
--------+---------+-------------
 hstore | ghstore | 
 hstore | hstore  | 
(2 rows)

postgres=# SHOW search_path;
   search_path   
-----------------
 "$user", public
(1 row)

postgres=# SELECT pg_type_is_visible('hstore.hstore'::regtype);
 pg_type_is_visible 
--------------------
 f
(1 row)

postgres=# SET search_path TO hstore;
SET

postgres=# SELECT pg_type_is_visible('hstore.hstore'::regtype);
 pg_type_is_visible 
--------------------
 t
(1 row)

如果类型不存在,或者类型存在但未进行模式限定且不在当前搜索路径中,则会引发 ERROR

postgres=# SELECT pg_type_is_visible('foo'::regtype);
ERROR:  type "foo" does not exist
LINE 1: SELECT pg_type_is_visible('foo'::regtype);

postgres=# SHOW search_path;
   search_path   
-----------------
 "$user", public
(1 row)

postgres=# SELECT pg_type_is_visible('hstore'::regtype);
ERROR:  type "hstore" does not exist
LINE 1: SELECT pg_type_is_visible('hstore'::regtype);

分类

数据类型, 模式 (命名空间), 系统函数

另请参阅

pg_collation_is_visible(), pg_function_is_visible(), pg_opclass_is_visible(), pg_operator_is_visible(), pg_opfamily_is_visible(), pg_table_is_visible()

反馈

在此处 提交关于“pg_type_is_visible()”的任何评论、建议或更正