3

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

Lev
  • 233
  • 1
  • 9

1 Answers1

2

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.

jjanes
  • 42,332
  • 3
  • 44
  • 54