pg_operator_is_visible()

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

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

pg_operator_is_visible()PostgreSQL 7.3 中添加。

用法

pg_operator_is_visible ( operator oid ) → boolean

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

变更历史

示例

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

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()" 的评论、建议或更正 此处