pg_function_is_visible()

一个用于确定函数在当前搜索路径中是否可见的函数

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

pg_function_is_visible()PostgreSQL 7.3 中添加。

用法

pg_function_is_visible ( function oid ) → boolean

可以使用 regprocregprocedure OID 别名包含函数名称的文本值来提供 function 参数。在这种情况下,名称应提供为模式限定值(例如,“someschema.somefunction”),否则如果函数存在但不在当前搜索路径中可见,将引发 ERROR

变更历史

示例

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

postgres=# CREATE EXTENSION hstore WITH SCHEMA hstore ;
CREATE EXTENSION

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

postgres=# SELECT hstore(ROW(1,2));
ERROR:  function hstore(record) does not exist
LINE 1: SELECT hstore(ROW(1,2));
               ^
HINT:  No function matches the given name and argument types. You might need to add explicit type casts.

postgres=# SELECT hstore.hstore(ROW(1,2));
        hstore        
----------------------
 "f1"=>"1", "f2"=>"2"
(1 row)

postgres=# SELECT pg_function_is_visible('hstore.hstore(record)'::regprocedure);
 pg_function_is_visible 
------------------------
 f
(1 row)

postgres=# SET search_path TO public,hstore;
SET

postgres=# SELECT pg_function_is_visible('hstore.hstore(record)'::regprocedure);
 pg_function_is_visible 
------------------------
 t
(1 row)

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

postgres=# SELECT pg_function_is_visible('foo'::regproc);
ERROR:  function "foo" does not exist
LINE 1: SELECT pg_function_is_visible('foo'::regproc);

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

postgres=# SELECT pg_function_is_visible('hstore(record)'::regprocedure);
ERROR:  function "hstore(record)" does not exist
LINE 1: SELECT pg_function_is_visible('hstore(record)'::regprocedure...

分类

函数和过程模式(命名空间)系统函数

另请参阅

pg_collation_is_visible()pg_opclass_is_visible()pg_operator_is_visible()pg_opfamily_is_visible()pg_table_is_visible()pg_type_is_visible()

反馈

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