功能体在系统目录中的哪里存储? [英] Where in the system catalog is the function body stored?

查看:64
本文介绍了功能体在系统目录中的哪里存储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的数据库构建一个文档系统,我想包括我的函数和触发器的来源。

I am trying to build a documentation system for my database and I would like to include the source of my functions and triggers.

我设法找到了所有元数据有关函数和触发器,但是这些函数和触发器的实际主体存储在哪里?

I managed to find all of the metadata on functions and triggers, but where is the actual body of these functions and triggers stored?

推荐答案

使用函数 pg_get_functiondef() 获取完整的函数定义:

Use the function pg_get_functiondef() to get the complete function definition:

SELECT pg_get_functiondef('my_schema.my_func(int)'::regprocedure)

强制转换为对象标识符 regprocedure 是获取 oid 函数,您可以将其馈给上述函数。

The cast to the object identifier regprocedure is the simplest way to get the oid of your function, which you feed to the above function.

pg_catalog.pg_proc 上的手册:

The manual on pg_catalog.pg_proc:


对于内置和动态加载的编译函数, prosrc
包含函数的C语言名称(链接符号)。对于所有其他
当前已知的语言类型, prosrc 包含函数的源文本。

For compiled functions, both built-in and dynamically loaded, prosrc contains the function's C-language name (link symbol). For all other currently-known language types, prosrc contains the function's source text.

仅检索函数主体:

SELECT prosrc 
FROM   pg_proc
WHERE  oid = 'my_schema.my_func(int)'::regprocedure;

这篇关于功能体在系统目录中的哪里存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆