A foreign join planning hook now considers a (foreign-table x function-RTE) INNER join as a push-down candidate when the function expression is IMMUTABLE and otherwise shippable. The remote query absorbs the function call as a FROM-list item (e.g. unnest(...) AS f<rti>(c1, c2, ...)), so the foreign side returns only rows that match the function-produced set and the join executes entirely on the remote. An IMMUTABLE function gives the same result on any server, so the same function RTE can be a push-down candidate for several distinct foreign servers without semantic risk. To keep the planner state consistent across those independent attempts, the per-call stub fpinfo for the function side lives on the joinrel's PgFdwRelationInfo (new outer_func_fpinfo / inner_func_fpinfo), never on the function rel itself, and the function side is detected via rtekind rather than fdw_private. set_foreign_rel_properties() propagates fdwroutine onto a joinrel that pairs a foreign rel with an RTE_FUNCTION rel so GetForeignJoinPaths gets called; the FDW retains full control over whether to actually generate a path. deparseRangeTblRef and deparseColumnRef gain a FUNCTION-RTE branch that emits the function expression and resolves Vars to the generated column aliases. Discussion: https://postgr.es/m/e3af56f9b2f1bd9fdf12aff6ca25b18d%40postgrespro.ru Author: Alexander Pyhalov <a.pyhalov@postgrespro.ru> Reviewed-by: Solaimurugan Vellaipandiyan <drsolaimurugan.v@gmail.com> Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
PostgreSQL Database Management System
This directory contains the source code distribution of the PostgreSQL database management system.
PostgreSQL is an advanced object-relational database management system that supports an extended subset of the SQL standard, including transactions, foreign keys, subqueries, triggers, user-defined types and functions. This distribution also contains C language bindings.
Copyright and license information can be found in the file COPYRIGHT.
General documentation about this version of PostgreSQL can be found at https://www.postgresql.org/docs/devel/. In particular, information about building PostgreSQL from the source code can be found at https://www.postgresql.org/docs/devel/installation.html.
The latest version of this software, and related software, may be obtained at https://www.postgresql.org/download/. For more information look at our web site located at https://www.postgresql.org/.