pg_identify_object() 是一个系统函数,它返回用于唯一标识指定对象的机器可读数据。
pg_identify_object() 在 PostgreSQL 9.3 中添加。
用法
pg_identify_object (classidoid,objidoid,objsubidinteger)
→ record (typetext,schematext,nametext,identitytext)
变更历史
- PostgreSQL 9.3
- 添加于 (提交 f8348ea3)
示例
pg_identify_object() 的基本用法示例
postgres=# CREATE FUNCTION bar (int) RETURNS int LANGUAGE SQL AS 'SELECT 1';
CREATE FUNCTION
postgres=# SELECT * FROM pg_get_object_address('function', '{bar}', '{int}');
classid | objid | objsubid
---------+-------+----------
1255 | 16511 | 0
(1 row)
postgres=# SELECT * FROM pg_identify_object ( 1255, 16511, 0);
type | schema | name | identity
----------+--------+------+---------------------
function | public | | public.bar(integer)
(1 row)
通过 pg_get_object_address() 生成标识
postgres=# SELECT (pg_identify_object(addr.classid, addr.objid, addr.objsubid)).*
FROM pg_get_object_address('table', '{foo}','{}') addr;
type | schema | name | identity
-------+--------+------+------------
table | public | foo | public.foo
(1 row)
postgres=# SELECT (pg_identify_object(addr.classid, addr.objid, addr.objsubid)).*
FROM pg_get_object_address('table column', '{foo,id}','{}') addr;
type | schema | name | identity
--------------+--------+------+---------------
table column | public | foo | public.foo.id
(1 row)
参考资料
- PostgreSQL 文档: 对象信息和寻址函数
