All we need is an easy explanation of the problem, so here it is.
Is it possible to execute functions that are located on a foreign server using
postgres_fdw? If not, is there any available workaround?
How to solve :
I know you bored from this bug, So we are here to help you! Take a deep breath and look at the explanation of your problem. We have many solutions to this problem, But we recommend you to use the first method because it is tested & true method that will 100% work for you.
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.
Note: Use and implement method 1 because this method fully tested our system.
Thank you 🙂