From 9e9931d2bf40e2fea447d779c2e133c2c1256ef3 Mon Sep 17 00:00:00 2001 From: Etsuro Fujita Date: Tue, 15 Aug 2023 16:45:00 +0900 Subject: Re-allow FDWs and custom scan providers to replace joins with pseudoconstant quals. This was disabled in commit 6f80a8d9c due to the lack of support for handling of pseudoconstant quals assigned to replaced joins in createplan.c. To re-allow it, this patch adds the support by 1) modifying the ForeignPath and CustomPath structs so that if they represent foreign and custom scans replacing a join with a scan, they store the list of RestrictInfo nodes to apply to the join, as in JoinPaths, and by 2) modifying create_scan_plan() in createplan.c so that it uses that list in that case, instead of the baserestrictinfo list, to get pseudoconstant quals assigned to the join, as mentioned in the commit message for that commit. Important item for the release notes: this is non-backwards-compatible since it modifies the ForeignPath and CustomPath structs, as mentioned above, and changes the argument lists for FDW helper functions create_foreignscan_path(), create_foreign_join_path(), and create_foreign_upper_path(). Richard Guo, with some additional changes by me, reviewed by Nishant Sharma, Suraj Kharage, and Richard Guo. Discussion: https://postgr.es/m/CADrsxdbcN1vejBaf8a%2BQhrZY5PXL-04mCd4GDu6qm6FigDZd6Q%40mail.gmail.com --- doc/src/sgml/custom-scan.sgml | 16 ++++++++++++++++ doc/src/sgml/fdwhandler.sgml | 11 +++++++++++ 2 files changed, 27 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/custom-scan.sgml b/doc/src/sgml/custom-scan.sgml index cd989e7d3c4..836776b27bd 100644 --- a/doc/src/sgml/custom-scan.sgml +++ b/doc/src/sgml/custom-scan.sgml @@ -62,6 +62,7 @@ typedef struct CustomPath Path path; uint32 flags; List *custom_paths; + List *custom_restrictinfo; List *custom_private; const CustomPathMethods *methods; } CustomPath; @@ -85,6 +86,10 @@ typedef struct CustomPath An optional custom_paths is a list of Path nodes used by this custom-path node; these will be transformed into Plan nodes by planner. + As described below, custom paths can be created for join relations as + well. In such a case, custom_restrictinfo + should be used to store the set of join clauses to apply to the join the + custom path replaces. Otherwise it should be NIL. custom_private can be used to store the custom path's private data. Private data should be stored in a form that can be handled by nodeToString, so that debugging routines that attempt to @@ -114,6 +119,17 @@ extern PGDLLIMPORT set_join_pathlist_hook_type set_join_pathlist_hook; responsibility of the hook to minimize duplicated work. + + Note also that the set of join clauses to apply to the join, + which is passed as extra->restrictlist, varies + depending on the combination of inner and outer relations. A + CustomPath path generated for the + joinrel must contain the set of join clauses it uses, + which will be used by the planner to convert the + CustomPath path into a plan, if it is selected + by the planner as the best path for the joinrel. + + Custom Scan Path Callbacks diff --git a/doc/src/sgml/fdwhandler.sgml b/doc/src/sgml/fdwhandler.sgml index ac1717bc3c4..25832d227fb 100644 --- a/doc/src/sgml/fdwhandler.sgml +++ b/doc/src/sgml/fdwhandler.sgml @@ -333,6 +333,17 @@ GetForeignJoinPaths(PlannerInfo *root, the responsibility of the FDW to minimize duplicated work. + + Note also that the set of join clauses to apply to the join, + which is passed as extra->restrictlist, varies + depending on the combination of inner and outer relations. A + ForeignPath path generated for the + joinrel must contain the set of join clauses it uses, + which will be used by the planner to convert the + ForeignPath path into a plan, if it is selected + by the planner as the best path for the joinrel. + + If a ForeignPath path is chosen for the join, it will represent the entire join process; paths generated for the component -- cgit v1.2.3