C# 我可以用c提取postgresql存储过程元数据吗
我希望传递一个包含存储过程名称的字符串,并检索元数据、该过程的参数和/或正文(如果可能),使用Npgsql dot net提供程序cC# 我可以用c提取postgresql存储过程元数据吗,c#,postgresql,metadata,npgsql,C#,Postgresql,Metadata,Npgsql,我希望传递一个包含存储过程名称的字符串,并检索元数据、该过程的参数和/或正文(如果可能),使用Npgsql dot net提供程序c 某人能给出代码片段吗 有两个有趣的功能: SELECT pg_catalog.pg_get_function_arguments('foobar'::regproc); SELECT pg_catalog.pg_get_functiondef('foobar'::regproc); 带有额外关联函数的输出示例,该函数将制表符转换为空格: denis=# sel
某人能给出代码片段吗 有两个有趣的功能:
SELECT pg_catalog.pg_get_function_arguments('foobar'::regproc);
SELECT pg_catalog.pg_get_functiondef('foobar'::regproc);
带有额外关联函数的输出示例,该函数将制表符转换为空格:
denis=# select pg_get_function_arguments('defproc'::regproc);
pg_get_function_arguments
---------------------------
_proc regprocedure
(1 row)
denis=# select pg_get_functiondef('defproc'::regproc);
pg_get_functiondef
---------------------------------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION public.defproc(_proc regprocedure)
RETURNS text
LANGUAGE plpgsql
STABLE STRICT
SET search_path TO "$user",public
AS $function$
DECLARE
_def text;
_eol text;
_unindent text;
_untabbed text;
line text;
pos int;
BEGIN
_def := pg_get_functiondef($1);
_eol := (regexp_matches(_def, E'\\r?\\n'))[1];
_unindent := (regexp_matches(_def, _eol || E'AS\\s*\\$(?:functionx*)\\$' || _eol || E'(\\t*)'))[1];
IF _unindent <> ''
THEN
_def := regexp_replace(_def, '^' || _unindent, '', 'gn');
END IF;
FOR line IN
SELECT regexp_split_to_table(_def, _eol) as line
LOOP
line = trim(trailing E' \t' from line);
LOOP
pos := position(E'\t' in line);
IF pos = 0
THEN
EXIT;
END IF;
line := substring(line from 1 for pos - 1) ||
repeat(' ', 4 - (pos % 4)) ||
substring(line from pos + 1 for length(line));
END LOOP;
_untabbed := COALESCE(_untabbed || _eol, '') || line;
END LOOP;
RETURN _untabbed;
END;
$function$
(1 row)