pg_operator_is_visible()
是一个系统函数,用于确定运算符在当前搜索路径中是否可见。
pg_operator_is_visible()
在 PostgreSQL 7.3 中添加。
用法
pg_operator_is_visible (operator
oid
) →boolean
operator
参数可以作为文本值提供,其中包含 regoperator
OID 别名,包含运算符的名称。在这种情况下,名称应作为模式限定值提供(例如 "someschema.someoperator
"),否则如果运算符存在但在当前搜索路径中不可见,则会引发 ERROR
。
变更历史
- PostgreSQL 7.3
- 添加 (提交 4ab8e690)
示例
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...
参考文献
- PostgreSQL 文档: 模式可见性查询函数