3

Is it possible to execute functions that are located on a foreign server using postgres_fdw? If not, is there any available workaround?

1
  • 2
    I think dblink is your only option for that.
    – user1822
    Jun 9, 2022 at 7:54

1 Answer 1

1

You can wrap the function in a view on the foreign side, then map a foreign table onto that view. This isn't very flexible as you can't specify the arguments to the function--either it must take no arguments, or they must be specified at the time the view is created.

Or, you can use dblink to execute arbitrary SQL on a foreign PostgreSQL server. This is pretty annoying, but if you already have a foreign server defined using postgres_fdw, you can at least give dblink's functions the name of that server rather than needing to give them a connection string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.