PostgreSQL提取函数源 [英] postgresql extracting function source
问题描述
需要使用SQL提取PostgreSQL函数的源.
Need to extract the source of a PostgreSQL function using SQL.
我看到其中一个功能有这种奇怪的行为,所有其他功能(大约200多个)都可以正常工作.
I am seeing this odd behavior with one of the function, all other functions (around 200+ ) work absolutely fine.
当我运行以下语句时,它会起作用:
When I run the following statement, it works:
select prosrc from pg_proc where proname= 'accounts_count';
但是,当我运行以下命令时,它将返回一个空字符串:
However when I run the following, it returns an empty string:
select routine_definition
from information_schema.routines
where specific_name = 'accounts_count_66243'
PostgreSQL版本8.3.我已经尝试过同时使用pgAdmin III和psql.
PostgreSQL version 8.3. I have tried using both pgAdmin III and psql.
这不是表演的制止器,但有助于了解为什么会出现这种情况.
Not a show stopper, but would be useful to know why this might be.
有任何想法吗?
推荐答案
如果查看information_schema.routines的定义,则可以找到以下过滤器:
if you look on definition of information_schema.routines, then you can find following filter:
FROM pg_namespace n, pg_proc p, pg_language l, pg_type t, pg_namespace nt
WHERE n.oid = p.pronamespace AND p.prolang = l.oid AND p.prorettype = t.oid
AND t.typnamespace = nt.oid AND (pg_has_role(p.proowner, 'USAGE'::text)
OR has_function_privilege(p.oid, 'EXECUTE'::text));
所以我的理论是
- 相关功能的权利和所有权存在一些问题(可能是)-尝试使用不同的帐户对此理论进行验证(postgres最好)
这篇关于PostgreSQL提取函数源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!