Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Loading Postgres functions with dependencies

I'm using quite a few Postgres functions (both sql and pl/pgsql) in a particular application. Some of the sql functions depend on other sql functions, e.g.

create or replace function my_function ()
  returns table (a text, b text) as
    $$
      select * from my_other_function();
    $$
  language sql;

For my_function to load properly, my_other_function has to be loaded first, else I get a my_other_function does not exist error. To manage this, I have been manually ensuring that my_other_function does get loaded first, but it would be nice not to have to do that.

In other words, is there a way to load all of my functions without regard to order and somehow check that all the necessary dependencies are available (function objects) after the fact?

I'm using Postgres 9.6.

like image 704
Mark McKelvy Avatar asked Apr 09 '26 13:04

Mark McKelvy


1 Answers

You can use SETcheck_function_bodies= false; prior creating your functions to suppress the error.

like image 156
sticky bit Avatar answered Apr 11 '26 04:04

sticky bit



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!