pg_operator_is_visible()

一个用于确定运算符是否可见的函数

pg_operator_is_visible() 是一个系统函数,用于确定运算符在当前搜索路径中是否可见。

pg_operator_is_visible() 函数在 PostgreSQL 7.3 中被添加。

用法

pg_operator_is_visible ( operator oid ) → boolean

可以使用包含运算符名称的 regoperator OID 别名 以文本值的形式提供 operator 参数。在这种情况下,名称应提供为模式限定值(例如,“someschema.someoperator”),否则如果运算符存在但对当前搜索路径不可见,则会引发 ERROR

变更历史

示例

假设 hstore 扩展已安装到 hstore 模式中,pg_operator_is_visible() 的示例如下:

postgres=# \do hstore.%*
                             List of operators
 Schema | Name | Left arg type | Right arg type | Result type | Description 
--------+------+---------------+----------------+-------------+-------------
 hstore | %#   |               | hstore.hstore  | text[]      | 
 hstore | %%   |               | hstore.hstore  | text[]      | 
(2 rows)

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

postgres=# SELECT pg_operator_is_visible('hstore.%#(NONE,hstore.hstore)'::regoperator);
 pg_operator_is_visible 
------------------------
 f
(1 row)

postgres=# SET search_path TO hstore;
SET

postgres=# SELECT pg_operator_is_visible('hstore.%#(NONE,hstore.hstore)'::regoperator);
 pg_operator_is_visible 
------------------------
 t
(1 row)

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

postgres=# SELECT pg_operator_is_visible('@@@(NONE,int)'::regoperator);
ERROR:  operator does not exist: @@@(NONE,int)
LINE 1: SELECT pg_operator_is_visible('@@@(NONE,int)'::regoperator);
                                      ^

postgres=# SHOW search_path;
   search_path   
-----------------
 "$user", public
(1 row) 
postgres=# SELECT pg_operator_is_visible('%#(NONE,hstore.hstore)'::regoperator);
ERROR:  operator does not exist: %#(NONE,hstore.hstore)
LINE 1: SELECT pg_operator_is_visible('%#(NONE,hstore.hstore)'::rego...

分类

运算符, 模式 (命名空间), 系统函数

另请参阅

pg_opclass_is_visible(), pg_opfamily_is_visible()

反馈

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