简体   繁体   中英

Use foreign data wrapper for forwarding

The following architecture: Server A has access to Server B, Server B has access to Server C, but Server A has no direct access to Server C.

I can create a foreign server on Server B like this:

CREATE SERVER foreign_server_b_to_c
    FOREIGN DATA WRAPPER postgres_fdw
    OPTIONS (dbname 'db_on_server_c', host 'serverc', port '5432', fetch_size '100000');

I can create a foreign server on Server A like this:

CREATE SERVER foreign_server_a_to_b
    FOREIGN DATA WRAPPER postgres_fdw
    OPTIONS (dbname 'db_on_server_b', host 'serverb', port '5432', fetch_size '100000');

Is there a possible way to us the foreign data wrapper on Server B as a proxy for direct access from Server A to Server C?

I prefer a solution within the database architecture, but might consider a solution outside of this in case its feasible.

Yes, that is possible. Define a foreign table on B that accesses a table on C, and define a foreign table on A that accesses the foreign table on B. It is straightforward.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM