diff options
author | Etsuro Fujita <efujita@postgresql.org> | 2023-08-15 16:45:00 +0900 |
---|---|---|
committer | Etsuro Fujita <efujita@postgresql.org> | 2023-08-15 16:45:00 +0900 |
commit | 9e9931d2bf40e2fea447d779c2e133c2c1256ef3 (patch) | |
tree | 33ece047786463ecd497cdd8178ca51e5f65c200 /doc/src | |
parent | 5ffb7c775062ef18756e515ac96f06d012cbb950 (diff) | |
download | postgresql-9e9931d2bf40e2fea447d779c2e133c2c1256ef3.tar.gz postgresql-9e9931d2bf40e2fea447d779c2e133c2c1256ef3.zip |
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
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/custom-scan.sgml | 16 | ||||
-rw-r--r-- | doc/src/sgml/fdwhandler.sgml | 11 |
2 files changed, 27 insertions, 0 deletions
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 <structfield>custom_paths</structfield> is a list of <structname>Path</structname> nodes used by this custom-path node; these will be transformed into <structname>Plan</structname> nodes by planner. + As described below, custom paths can be created for join relations as + well. In such a case, <structfield>custom_restrictinfo</structfield> + should be used to store the set of join clauses to apply to the join the + custom path replaces. Otherwise it should be NIL. <structfield>custom_private</structfield> can be used to store the custom path's private data. Private data should be stored in a form that can be handled by <literal>nodeToString</literal>, 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. </para> + <para> + Note also that the set of join clauses to apply to the join, + which is passed as <literal>extra->restrictlist</literal>, varies + depending on the combination of inner and outer relations. A + <structname>CustomPath</structname> path generated for the + <literal>joinrel</literal> must contain the set of join clauses it uses, + which will be used by the planner to convert the + <structname>CustomPath</structname> path into a plan, if it is selected + by the planner as the best path for the <literal>joinrel</literal>. + </para> + <sect2 id="custom-scan-path-callbacks"> <title>Custom Scan Path Callbacks</title> 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 @@ -334,6 +334,17 @@ GetForeignJoinPaths(PlannerInfo *root, </para> <para> + Note also that the set of join clauses to apply to the join, + which is passed as <literal>extra->restrictlist</literal>, varies + depending on the combination of inner and outer relations. A + <structname>ForeignPath</structname> path generated for the + <literal>joinrel</literal> must contain the set of join clauses it uses, + which will be used by the planner to convert the + <structname>ForeignPath</structname> path into a plan, if it is selected + by the planner as the best path for the <literal>joinrel</literal>. + </para> + + <para> If a <structname>ForeignPath</structname> path is chosen for the join, it will represent the entire join process; paths generated for the component tables and subsidiary joins will not be used. Subsequent processing of |