加载具有依赖关系的 Postgres 函数
Loading Postgres functions with dependencies
我在特定应用程序中使用了相当多的 Postgres 函数(sql 和 pl/pgsql)。某些 sql 函数依赖于其他 sql 函数,例如
create or replace function my_function ()
returns table (a text, b text) as
$$
select * from my_other_function();
$$
language sql;
要使 my_function
正确加载,必须先加载 my_other_function
,否则会出现 my_other_function does not exist
错误。为了解决这个问题,我一直在手动确保 my_other_function
确实 首先加载,但最好不要那样做。
换句话说,有没有一种方法可以不考虑顺序地加载我的所有函数,并以某种方式检查所有必要的依赖项是否可用(函数对象)?
我正在使用 Postgres 9.6。
您可以在创建函数之前使用 SET
check_function_bodies
= false;
来抑制错误。
我在特定应用程序中使用了相当多的 Postgres 函数(sql 和 pl/pgsql)。某些 sql 函数依赖于其他 sql 函数,例如
create or replace function my_function ()
returns table (a text, b text) as
$$
select * from my_other_function();
$$
language sql;
要使 my_function
正确加载,必须先加载 my_other_function
,否则会出现 my_other_function does not exist
错误。为了解决这个问题,我一直在手动确保 my_other_function
确实 首先加载,但最好不要那样做。
换句话说,有没有一种方法可以不考虑顺序地加载我的所有函数,并以某种方式检查所有必要的依赖项是否可用(函数对象)?
我正在使用 Postgres 9.6。
您可以在创建函数之前使用 SET
check_function_bodies
= false;
来抑制错误。