美文网首页
postgresql的查询自定义函数信息(20.7.1)

postgresql的查询自定义函数信息(20.7.1)

作者: 剑道_7ffc | 来源:发表于2020-07-13 16:18 被阅读0次

查询自定义函数的信息

SELECT 
    pg_type.typname AS "返回值数据类型",
    pg_proc.proname AS "函数名称",
    pg_proc.proargnames AS "参数名称",
  proargtypes.proargtypeNames AS "参数类型名称",
    pg_proc.prosrc AS "函数内容",
    pg_proc.pronargs AS "参数个数"
FROM (
    SELECT 
        pg_proc.proname,
        pg_proc.proargtypes,    
        string_agg(COALESCE(pg_proc.typname,''), ',') proargtypeNames
    FROM (
        SELECT pg_proc.proname,
             pg_proc.proargtypes,
             pg_proc.proargtype,
             pg_type.typname,
             pg_proc.rowNumber
        FROM (
            SELECT pg_proc.*,
                   ROW_NUMBER() OVER() rowNumber
            FROM (
                SELECT pg_proc.proname,
                    pg_proc.proargtypes,
                    regexp_split_to_table(pg_proc.proargtypes::VARCHAR, ' ')::VARCHAR proargtype
                FROM pg_proc
                WHERE pronamespace = (SELECT pg_namespace.oid FROM pg_namespace WHERE nspname = 'public')
                            AND pg_proc.proname IN('tmp_test1','tmp_test2')
            ) pg_proc
        ) pg_proc
        LEFT JOIN pg_type ON pg_proc.proargtype = pg_type.oid::VARCHAR
        ORDER BY pg_proc.proname,pg_proc.proargtypes,pg_proc.rowNumber
    ) pg_proc
    GROUP BY pg_proc.proname,pg_proc.proargtypes
) proargtypes
INNER JOIN pg_proc ON proargtypes.proname = pg_proc.proname AND proargtypes.proargtypes = pg_proc.proargtypes
LEFT JOIN pg_type ON pg_proc.prorettype = pg_type.oid;
image.png

相关文章

网友评论

      本文标题:postgresql的查询自定义函数信息(20.7.1)

      本文链接:https://www.haomeiwen.com/subject/hbaacktx.html